Skip to content

Commit

Permalink
Add max connections and password capabilities. (#151)
Browse files Browse the repository at this point in the history
This pr adds max-connections as well as the ability to connect w/ a password
  • Loading branch information
Vinai Rachakonda authored Apr 23, 2021
1 parent d34516f commit 7b31d88
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 114 deletions.
18 changes: 14 additions & 4 deletions doltpy/sql/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ServerConfig:
loglevel: Optional[str] = None
multi_db_dir: Optional[str] = None
no_auto_commit: Optional[bool] = None
max_connections: Optional[int] = None
echo: bool = False


Expand All @@ -60,14 +61,21 @@ def _get_engine(self) -> Engine:
user = self.server_config.user
host = self.server_config.host
port = self.server_config.port
password = self.server_config.password

logger.info(f"Creating engine for Dolt SQL Server instance running on {host}:{port}")

def inner():
return create_engine(
f"mysql+mysqlconnector://{user}@{host}:{port}/{database}",
echo=self.server_config.echo,
)
if password is not None:
return create_engine(
f"mysql+mysqlconnector://{user}:{password}@{host}:{port}/{database}",
echo=self.server_config.echo,
)
else:
return create_engine(
f"mysql+mysqlconnector://{user}@{host}:{port}/{database}",
echo=self.server_config.echo,
)

return inner()

Expand Down Expand Up @@ -429,6 +437,8 @@ def inner(server_args):
args.extend(["--multi-db-dir", self.server_config.multi_db_dir])
if self.server_config.no_auto_commit:
args.extend(["--no-auto-commit"])
if self.server_config.max_connections:
args.extend(["--max-connections", str(self.server_config.max_connections)])

inner(args)

Expand Down
Loading

0 comments on commit 7b31d88

Please sign in to comment.