Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max connections and password capabilities. #151

Merged
merged 5 commits into from
Apr 23, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 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 @@ -428,6 +436,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