Skip to content

Commit 763f7cc

Browse files
fix: Remove charset setting - let server control encoding
Database charset/encoding should be configured on the server, not the client. Removes: - charset from ConnectionSettings - charset from connection template - charset parameter from adapter connect calls - charset from thread-safe mode spec Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b06e224 commit 763f7cc

File tree

4 files changed

+1
-13
lines changed

4 files changed

+1
-13
lines changed

docs/design/thread-safe-mode.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ All settings become connection-scoped and are accessed via `conn.config` (read/w
5252
| `stores` | dict | {} | Blob storage configuration |
5353
| `cache` | Path | None | Local cache directory |
5454
| `query_cache` | Path | None | Query cache directory |
55-
| `charset` | str | "" | Connection charset |
5655
| `reconnect` | bool | True | Auto-reconnect on lost connection |
5756
| `display_limit` | int | 12 | Max rows to display |
5857
| `display_width` | int | 14 | Column width for display |
@@ -365,7 +364,7 @@ class Connection:
365364
def from_config(cls, cfg=None, *, host=None, user=None, password=None,
366365
port=None, backend=None, safemode=None, stores=None,
367366
database_prefix=None, cache=None, query_cache=None,
368-
charset=None, reconnect=None, init_fun=None,
367+
reconnect=None, init_fun=None,
369368
use_tls=None) -> "Connection":
370369
"""
371370
Create connection with explicit configuration.
@@ -388,7 +387,6 @@ class Connection:
388387
**({"database_prefix": database_prefix} if database_prefix is not None else {}),
389388
**({"cache": cache} if cache is not None else {}),
390389
**({"query_cache": query_cache} if query_cache is not None else {}),
391-
**({"charset": charset} if charset is not None else {}),
392390
**({"reconnect": reconnect} if reconnect is not None else {}),
393391
)
394392

@@ -421,7 +419,6 @@ class ConnectionConfig:
421419
"stores": {},
422420
"cache": None,
423421
"query_cache": None,
424-
"charset": "",
425422
"reconnect": True,
426423
"display_limit": 12,
427424
"display_width": 14,

src/datajoint/adapters/mysql.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def connect(
7878
- init_command: SQL initialization command
7979
- ssl: TLS/SSL configuration dict (deprecated, use use_tls)
8080
- use_tls: bool or dict - DataJoint's SSL parameter (preferred)
81-
- charset: Character set (default from kwargs)
8281
8382
Returns
8483
-------
@@ -91,7 +90,6 @@ def connect(
9190
# Convert boolean True to dict for PyMySQL (PyMySQL expects dict or SSLContext)
9291
if ssl_config is True:
9392
ssl_config = {} # Enable SSL with default settings
94-
charset = kwargs.get("charset", "")
9593

9694
# Prepare connection parameters
9795
conn_params = {
@@ -102,7 +100,6 @@ def connect(
102100
"init_command": init_command,
103101
"sql_mode": "NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,"
104102
"STRICT_ALL_TABLES,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY",
105-
"charset": charset,
106103
"autocommit": True, # DataJoint manages transactions explicitly
107104
}
108105

src/datajoint/connection.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ def __init__(
222222
self._conn = None
223223
self._query_cache = None
224224
self._is_closed = True # Mark as closed until connect() succeeds
225-
# Store charset to avoid global config access in connect()
226-
self._charset = "" if config.thread_safe else config.connection.charset
227225
# Store reconnect setting for query() method
228226
self._reconnect = True if config.thread_safe else config.database.reconnect
229227

@@ -414,7 +412,6 @@ def connect(self) -> None:
414412
user=self.conn_info["user"],
415413
password=self.conn_info["passwd"],
416414
init_command=self.init_fun,
417-
charset=self._charset,
418415
use_tls=self.conn_info.get("ssl"),
419416
)
420417
except Exception as ssl_error:
@@ -431,7 +428,6 @@ def connect(self) -> None:
431428
user=self.conn_info["user"],
432429
password=self.conn_info["passwd"],
433430
init_command=self.init_fun,
434-
charset=self._charset,
435431
use_tls=False, # Explicitly disable SSL for fallback
436432
)
437433
else:

src/datajoint/settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ class ConnectionSettings(BaseSettings):
225225
model_config = SettingsConfigDict(extra="forbid", validate_assignment=True)
226226

227227
init_function: str | None = None
228-
charset: str = "" # pymysql uses '' as default
229228

230229

231230
class DisplaySettings(BaseSettings):
@@ -825,7 +824,6 @@ def save_template(
825824
},
826825
"connection": {
827826
"init_function": None,
828-
"charset": "",
829827
},
830828
"display": {
831829
"limit": 12,

0 commit comments

Comments
 (0)