Skip to content

Commit

Permalink
repair _dsn_template on some drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
phenobarbital committed Jan 10, 2025
1 parent 2481828 commit a7b44ea
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 13 deletions.
21 changes: 11 additions & 10 deletions asyncdb/drivers/cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def record_factory(colnames, rows):
class cassandra(InitDriver):
_provider = "cassandra"
_syntax = "cql"
_dsn_template = "cassandra://{username}:{password}@{host}:{port}/{database}"

def __init__(self, loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs):
self.hosts: list = []
Expand Down Expand Up @@ -102,16 +103,16 @@ async def connection(self, keyspace=None):
self._connected = False
self._cluster = None
try:
try:
if self.params["ssl"] is not None:
ssl_opts = {
"ca_certs": self.params["ssl"]["certfile"],
"ssl_version": PROTOCOL_TLSv1,
"keyfile": self.params["ssl"]["userkey"],
"certfile": self.params["ssl"]["usercert"],
}
except KeyError:
ssl_opts = {}
if self.params["ssl"] is not None:
ssl_opts = {
"ca_certs": self.params["ssl"]["certfile"],
"ssl_version": PROTOCOL_TLSv1,
"keyfile": self.params["ssl"]["userkey"],
"certfile": self.params["ssl"]["usercert"],
}
except KeyError:
ssl_opts = {}
try:
if self.whitelist:
policy = WhiteListRoundRobinPolicy(self.whitelist)
else:
Expand Down
1 change: 1 addition & 0 deletions asyncdb/drivers/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
class delta(InitDriver):
_provider = "delta"
_syntax = "nosql"
_dsn_template = "" # DeltaTable DSN template, not used in this driver.

def __init__(self, loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:

Expand Down
2 changes: 2 additions & 0 deletions asyncdb/drivers/hazel.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def get_class_id(self):
class hazel(InitDriver):
_provider = "hazelcast"
_syntax = "sql"
_dsn_template = ""


def __init__(self, dsn: str = None, loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs):
self._test_query = None
Expand Down
2 changes: 2 additions & 0 deletions asyncdb/drivers/jdbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
class jdbc(SQLDriver, DatabaseBackend, ModelBackend):
_provider = "JDBC"
_syntax = "sql"
_dsn_template: str = ""


def __init__(self, dsn: str = "", loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:
self._test_query = "SELECT 1"
Expand Down
1 change: 1 addition & 0 deletions asyncdb/drivers/mcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class mcache(InitDriver):
_provider = "memcache"
_syntax = "nosql"
_behaviors = {"tcp_nodelay": True, "ketama": True}
_dsn_template = "" # Memcached DSN template, not used in this driver.

def __init__(self, loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:
super(mcache, self).__init__(loop=loop, params=params, **kwargs)
Expand Down
1 change: 1 addition & 0 deletions asyncdb/drivers/memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class memcachePool(BasePool):
"""
Pool-based version of Memcached connector.
"""
_dsn_template = "" # Memcached DSN template, not used in this driver.

def __init__(self, dsn: str = "", loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:
self._dsn = None
Expand Down
3 changes: 2 additions & 1 deletion asyncdb/drivers/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ class mssql(SQLDriver, DBCursorBackend):
_syntax = "sql"
_test_query = "SELECT 1 as one"
_charset: str = "UTF8"
_dsn_template: str = ''


def __init__(self, dsn: str = "", loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:
self._dsn = ""
self._query_raw = "SELECT {fields} FROM {table} {where_cond}"
self._version: str = None
self.application_name = os.getenv("APP_NAME", "NAV")
self._server_settings: dict = []
self._connected: bool = False
try:
self.tds_version = kwargs["tds_version"]
del kwargs["tds_version"]
Expand Down
2 changes: 1 addition & 1 deletion asyncdb/drivers/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class oracle(SQLDriver):

_provider = "oracle"
_syntax = "sql"
_dsn_template: str = "{host}:{port}/{database}"

def __init__(self, dsn: str = "", loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:
"""
Expand All @@ -51,7 +52,6 @@ def __init__(self, dsn: str = "", loop: asyncio.AbstractEventLoop = None, params
"""
self._test_query = "SELECT 1 FROM dual"
_starttime = datetime.now()
self._dsn = "{host}:{port}/{database}"
self._database = None
self.application_name = os.getenv("APP_NAME", "ASYNCDB")
if params:
Expand Down
1 change: 1 addition & 0 deletions asyncdb/drivers/rethink.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async def fetch_all(self) -> Iterable[dict]:
class rethink(InitDriver, DBCursorBackend):
_provider = "rethink"
_syntax = "rql"
_dsn_template: str = ''

def __init__(self, loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs):
self.conditions = {}
Expand Down
1 change: 1 addition & 0 deletions asyncdb/drivers/scylladb.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def record_factory(colnames, rows):
class scylladb(InitDriver, ModelBackend):
_provider = "scylladb"
_syntax = "cql"
_dsn_template: str = ''

def __init__(self, loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs):
self.hosts: list = []
Expand Down
2 changes: 2 additions & 0 deletions asyncdb/drivers/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class SQLDriver(BaseDBDriver):

_syntax = "sql"
_test_query = "SELECT 1"
_dsn_template: str = ""


def __init__(self, dsn: str = "", loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:
self._query_raw = "SELECT {fields} FROM {table} {where_cond}"
Expand Down
1 change: 1 addition & 0 deletions asyncdb/drivers/sqlserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class sqlserver(mssql):
"""

_provider = "sqlserver"
_dsn_template: str = ''

def __init__(self, dsn: str = "", loop: asyncio.AbstractEventLoop = None, params: dict = None, **kwargs) -> None:
try:
Expand Down
2 changes: 1 addition & 1 deletion asyncdb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__title__ = "asyncdb"
__description__ = "Library for Asynchronous data source connections \
Collection of asyncio drivers."
__version__ = "2.10.1"
__version__ = "2.10.2"
__copyright__ = "Copyright (c) 2020-2024 Jesus Lara"
__author__ = "Jesus Lara"
__author_email__ = "[email protected]"
Expand Down

0 comments on commit a7b44ea

Please sign in to comment.