Skip to content

Commit

Permalink
remove the stupid print i left!!
Browse files Browse the repository at this point in the history
use query with make url
  • Loading branch information
endurance committed Apr 29, 2021
1 parent 11f9064 commit bb269f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions kfai_sql_chemistry/db/database_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ def from_local_env(prefix_str: str):
)
return cfg

def make_url(self):
def make_url(self, query=None):
return URL(
self.engine,
username=self.username,
password=self.password,
host=self.host,
port=self.port,
database=self.dbname or self.db_name
database=self.dbname or self.db_name,
query=query
)
6 changes: 2 additions & 4 deletions kfai_sql_chemistry/db/engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ def create_all_engines(self, database_map: Dict[str, DatabaseConfig]):
# https://docs.sqlalchemy.org/en/13/dialects/mysql.html#charset-selection
# Mysql requires specific encoding
if "mysql" in cfg.engine:
print(cfg.make_url())
engine: Engine = create_engine(
f"{cfg.make_url()}?charset=utf8mb4", pool_recycle=3600
)
url = cfg.make_url(query={'charset': 'utf8mb4'})
engine: Engine = create_engine(f"{url}", pool_recycle=3600)
else:
engine: Engine = create_engine(cfg.make_url(), pool_recycle=3600)
self._engines[db_name] = engine
Expand Down

0 comments on commit bb269f4

Please sign in to comment.