Skip to content

Commit 62f4795

Browse files
committed
review comment
1 parent 2d9faf7 commit 62f4795

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎mssql_python/cursor.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2573,6 +2573,12 @@ def generate_data():
25732573
if not params.get("server"):
25742574
raise ValueError("SERVER parameter is required in connection string")
25752575

2576+
if not params.get("database"):
2577+
raise ValueError(
2578+
"DATABASE parameter is required in connection string for bulk copy. "
2579+
"Specify the target database explicitly to avoid accidentally writing to system databases."
2580+
)
2581+
25762582
# Build connection context for Rust library
25772583
# Note: Password is extracted separately to avoid storing it in the main context
25782584
# dict that could be accidentally logged or exposed in error messages.
@@ -2593,8 +2599,8 @@ def generate_data():
25932599
encryption = "Optional"
25942600

25952601
context = {
2596-
"server": params.get("server", "localhost"),
2597-
"database": params.get("database", "master"),
2602+
"server": params.get("server"),
2603+
"database": params.get("database"),
25982604
"user_name": params.get("uid", ""),
25992605
"trust_server_certificate": trust_cert,
26002606
"encryption": encryption,

0 commit comments

Comments
 (0)