-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlalchemy_rdsdataapi.py
More file actions
33 lines (25 loc) · 892 Bytes
/
sqlalchemy_rdsdataapi.py
File metadata and controls
33 lines (25 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from sqlalchemy.dialects import registry
from sqlalchemy.engine.default import DefaultDialect
try:
from urllib.parse import urlparse, unquote # python 3
except ImportError:
from urlparse import urlparse, unquote # python 2
class RdsDataApiDialect(DefaultDialect):
name = "rdsdataapi"
driver = "rdsdataapi"
@classmethod
def dbapi(cls):
return __import__("rdsdataapi")
def create_connect_args(self, url):
kwargs = {}
if url.database:
kwargs["database"] = url.database
if url.host:
kwargs["resource_arn"] = unquote(url.host)
if url.username:
kwargs["secret_arn"] = unquote(url.username)
return [], kwargs
def _check_unicode_returns(self, connection):
return True
def register():
registry.register("rdsdataapi", "sqlalchemy_rdsdataapi", "RdsDataApiDialect")