Skip to content

Commit 04996e8

Browse files
committed
Added overrides for connection drivers. Got rid of enum for driver names so that users can use any of the supported drivers if they want to install all the pre-requisite packages needed. updated the readme to explain exactly what is included and pointed to the documentation on how to use things that aren't included.
1 parent 21c9a2f commit 04996e8

File tree

9 files changed

+24
-63
lines changed

9 files changed

+24
-63
lines changed

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
# SQL Integration Pack
2-
Query, Insert, Update, and Delete information from PostgreSQL, SQLite, MsSQL, MySQL, Oracle, Firebird, and Sybase Databases
2+
Query, Insert, Update, and Delete information from PostgreSQL, MsSQL, MySQL, Oracle, Firebird Databases. Additional databases can be added by installing the pre-requisite packes and passing the driver name as documented at [SQLAlchemy Dialects Doc](https://docs.sqlalchemy.org/en/latest/dialects/index.html).
33

4-
## Pre-Requisites
5-
This pack is set up to provide funcationality for the above databases. For MySQL and MsSQL we need to install 2 system packages.
4+
## Included Drivers
5+
This pack is already set up to connect to the databases listed above. Additional databases can be connected to but pre-requisite packages will need to be installed before the drivers will work. [SQLAlchemy Dialects Doc](https://docs.sqlalchemy.org/en/latest/dialects/index.html).
66

7-
#### [MySQL](https://pypi.org/project/mysqlclient/)
8-
``` shell
9-
yum install mysql-devel
7+
You can pass any of the following driver names without any additional packages needing installed.
108
```
11-
12-
#### [MsSQL](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017)
13-
``` shell
14-
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
15-
yum install msodbcsql17
16-
yum install unixODBC-devel
9+
postgresql
10+
mssql
11+
mysql
12+
oracle
13+
firebird
1714
```
1815

1916
## Quick Start

actions/delete.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@
3434
drivername:
3535
type: string
3636
description: "Optional override of the database_type in <connection> (required if <connection> is not specified). The type of database that is being connected to."
37-
enum:
38-
- postgresql
39-
- sqlite
40-
- mssql
41-
- mysql
42-
- oracle
43-
- firebird
44-
- sybase
4537
required: false
4638
table:
4739
type: string

actions/insert.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@
3434
drivername:
3535
type: string
3636
description: "Optional override of the database_type in <connection> (required if <connection> is not specified). The type of database that is being connected to."
37-
enum:
38-
- postgresql
39-
- sqlite
40-
- mssql
41-
- mysql
42-
- oracle
43-
- firebird
44-
- sybase
4537
required: false
4638
table:
4739
type: string

actions/insert_bulk.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@
3434
drivername:
3535
type: string
3636
description: "Optional override of the database_type in <connection> (required if <connection> is not specified). The type of database that is being connected to."
37-
enum:
38-
- postgresql
39-
- sqlite
40-
- mssql
41-
- mysql
42-
- oracle
43-
- firebird
44-
- sybase
4537
required: false
4638
table:
4739
type: string

actions/lib/base_action.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
('port', False, None),
1414
('drivername', True, "")]
1515

16+
DEFAULT_KNOWN_DRIVER_CONNECTORS = {
17+
'postgresql': 'postgresql+psycopg2',
18+
'mysql': 'mysql+pymysql',
19+
'oracle': 'oracle+cx_oracle',
20+
'mssql': 'mssql+pymssql',
21+
'firebird': 'firebird+fdb'
22+
}
1623

1724
class BaseAction(Action):
1825
def __init__(self, config):
@@ -106,6 +113,11 @@ def db_connection(self, kwargs_dict):
106113
# Get the connection details from either config or from action params
107114
connection = self.resolve_connection(kwargs_dict)
108115

116+
# Update Driver with a connector
117+
default_driver = DEFAULT_KNOWN_DRIVER_CONNECTORS.get(connection['drivername'], None)
118+
if default_driver:
119+
connection['drivername'] = default_driver
120+
109121
# Format the connection string
110122
database_connection_string = URL(**connection)
111123

actions/query.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@
3434
drivername:
3535
type: string
3636
description: "Optional override of the database_type in <connection> (required if <connection> is not specified). The type of database that is being connected to."
37-
enum:
38-
- postgresql
39-
- sqlite
40-
- mssql
41-
- mysql
42-
- oracle
43-
- firebird
44-
- sybase
4537
required: false
4638
query:
4739
type: string

actions/update.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@
3434
drivername:
3535
type: string
3636
description: "Optional override of the database_type in <connection> (required if <connection> is not specified). The type of database that is being connected to."
37-
enum:
38-
- postgresql
39-
- sqlite
40-
- mssql
41-
- mysql
42-
- oracle
43-
- firebird
44-
- sybase
4537
required: false
4638
table:
4739
type: string

config.schema.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,5 @@ connection:
3535
drivername:
3636
description: "The type of database that is being connected to."
3737
type: string
38-
enum:
39-
- postgresql
40-
- sqlite
41-
- mssql
42-
- mysql
43-
- oracle
44-
- firebird
45-
- sybase
4638
required: true
4739
additionalProperties: false

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sqlalchemy
2-
psycopg2
3-
mysqlclient
4-
pyodbc
2+
psycopg2 <=2.7.5
3+
pymysql
4+
pymssql
55
cx_Oracle
66
fdb

0 commit comments

Comments
 (0)