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

Support connecting via UNIX sockets #165

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Migrate CircleCI to GitHub Actions ([#120](https://github.com/dbeatty10/dbt-mysql/issues/120))
- Support dbt v1.4 ([#146](https://github.com/dbeatty10/dbt-mysql/pull/146))
- Support dbt v1.5 ([#145](https://github.com/dbeatty10/dbt-mysql/issues/145))
- Support connecting via UNIX sockets ([#164](https://github.com/dbeatty10/dbt-mysql/issues/164))

### Fixes
- Fix incremental composite keys ([#144](https://github.com/dbeatty10/dbt-mysql/issues/144))
Expand All @@ -12,7 +13,7 @@
- [@lpezet](https://github.com/lpezet) ([#146](https://github.com/dbeatty10/dbt-mysql/pull/146))
- [@moszutij](https://github.com/moszutij) ([#146](https://github.com/dbeatty10/dbt-mysql/pull/146), [#144](https://github.com/dbeatty10/dbt-mysql/issues/144))
- [@wesen](https://github.com/wesen) ([#146](https://github.com/dbeatty10/dbt-mysql/pull/146))
- [@mwallace582](https://github.com/mwallace582) ([#162](https://github.com/dbeatty10/dbt-mysql/pull/162), [#163](https://github.com/dbeatty10/dbt-mysql/pull/163))
- [@mwallace582](https://github.com/mwallace582) ([#162](https://github.com/dbeatty10/dbt-mysql/pull/162), [#163](https://github.com/dbeatty10/dbt-mysql/pull/163), [#164](https://github.com/dbeatty10/dbt-mysql/issues/164))


## dbt-mysql 1.1.0 (Feb 5, 2023)
Expand Down
10 changes: 8 additions & 2 deletions dbt/adapters/mariadb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

@dataclass(init=False)
class MariaDBCredentials(Credentials):
server: str
server: Optional[str] = None
unix_socket: Optional[str] = None
port: Optional[int] = None
database: Optional[str] = None
schema: str
Expand Down Expand Up @@ -62,6 +63,7 @@ def _connection_keys(self):
"""
return (
"server",
"unix_socket",
"port",
"database",
"schema",
Expand All @@ -81,14 +83,18 @@ def open(cls, connection):
credentials = cls.get_credentials(connection.credentials)
kwargs = {}

kwargs["host"] = credentials.server
kwargs["user"] = credentials.username
kwargs["passwd"] = credentials.password
kwargs["buffered"] = True

if credentials.ssl_disabled:
kwargs["ssl_disabled"] = credentials.ssl_disabled

if credentials.server:
kwargs["host"] = credentials.server
elif credentials.unix_socket:
kwargs["unix_socket"] = credentials.unix_socket

if credentials.port:
kwargs["port"] = credentials.port

Expand Down
10 changes: 8 additions & 2 deletions dbt/adapters/mysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

@dataclass(init=False)
class MySQLCredentials(Credentials):
server: str
server: Optional[str] = None
unix_socket: Optional[str] = None
port: Optional[int] = None
database: Optional[str] = None
schema: str
Expand Down Expand Up @@ -61,6 +62,7 @@ def _connection_keys(self):
"""
return (
"server",
"unix_socket",
"port",
"database",
"schema",
Expand All @@ -80,11 +82,15 @@ def open(cls, connection):
credentials = cls.get_credentials(connection.credentials)
kwargs = {}

kwargs["host"] = credentials.server
kwargs["user"] = credentials.username
kwargs["passwd"] = credentials.password
kwargs["buffered"] = True

if credentials.server:
kwargs["host"] = credentials.server
elif credentials.unix_socket:
kwargs["unix_socket"] = credentials.unix_socket

if credentials.port:
kwargs["port"] = credentials.port

Expand Down
10 changes: 8 additions & 2 deletions dbt/adapters/mysql5/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

@dataclass(init=False)
class MySQLCredentials(Credentials):
server: str
server: Optional[str] = None
unix_socket: Optional[str] = None
port: Optional[int] = None
database: Optional[str] = None
schema: str
Expand Down Expand Up @@ -62,6 +63,7 @@ def _connection_keys(self):
"""
return (
"server",
"unix_socket",
"port",
"database",
"schema",
Expand All @@ -81,14 +83,18 @@ def open(cls, connection):
credentials = cls.get_credentials(connection.credentials)
kwargs = {}

kwargs["host"] = credentials.server
kwargs["user"] = credentials.username
kwargs["passwd"] = credentials.password
kwargs["buffered"] = True

if credentials.ssl_disabled:
kwargs["ssl_disabled"] = credentials.ssl_disabled

if credentials.server:
kwargs["host"] = credentials.server
elif credentials.unix_socket:
kwargs["unix_socket"] = credentials.unix_socket

if credentials.port:
kwargs["port"] = credentials.port

Expand Down