Skip to content

Commit 1eecf36

Browse files
Merge pull request #84 from annabaas/feature/sqlserver
Feature/sqlserver
2 parents 8eeff41 + e15c56f commit 1eecf36

File tree

12 files changed

+92
-5
lines changed

12 files changed

+92
-5
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ services:
77

88
addons:
99
chrome: "stable"
10+
apt:
11+
packages:
12+
- unixodbc-dev # required for pyodbc
1013

1114
language: python
1215
python:
@@ -18,6 +21,12 @@ python:
1821
install:
1922
- pip install -r requirements/$TRAVIS_PYTHON_VERSION.txt
2023

24+
before_script: # add the mssql driver for xenial
25+
- curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
26+
- curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
27+
- sudo apt-get -qq update
28+
- sudo ACCEPT_EULA=Y apt-get -y install msodbcsql17
29+
2130
script:
2231
- flake8
2332
- py.test -sv --cov-config .coveragerc --cov-report html:skip-covered --cov-report term:skip-covered --cov=testcontainers --tb=short tests/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Currently available features:
1515
* MariaDb container
1616
* OracleDb container
1717
* PostgreSQL Db container
18+
* Microsoft SQL Server container
1819
* Generic docker containers
1920

2021
### Quick start

docs/database.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Necessary to use it:
6363

6464
- ``cx_Oracle``
6565
- `Oracle client libraries <https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html>`_
66-
=======
66+
6767
::
6868

6969
hostname: localhost
@@ -112,4 +112,18 @@ Example of MongoDb database usage:
112112
print(document)
113113

114114
Connection is made using pymongo package and MongoClient class.
115-
Alternatively, you can use get_connection_url method to use the driver that better fits for your use case.
115+
Alternatively, you can use get_connection_url method to use the driver that better fits for your use case.
116+
117+
Microsoft SQL Server
118+
--------------------
119+
120+
::
121+
122+
mssql = SqlServerContainer()
123+
124+
with mssql:
125+
e = sqlalchemy.create_engine(mssql.get_connection_url())
126+
result = e.execute("select @@VERSION")
127+
128+
It uses the Microsoft-provided Docker image and requires `ODBC Driver 17 for SQL Server
129+
<https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server>`_.

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Currently available features:
1717
- Google Cloud PubSub emulator container
1818
- Elasticsearch container
1919
- MongoDb container
20+
- MS SQL Server container
2021
- Generic Docker containers
2122

2223
Installation
@@ -35,6 +36,7 @@ and can be installed using pip, depending on which containers you need:
3536
pip install testcontainers[selenium]
3637
pip install testcontainers[google-cloud-pubsub]
3738
pip install testcontainers[mongodb]
39+
pip install testcontainers[mssqlserver]
3840
# or with multiple
3941
pip install testcontainers[mysql,postgresql,selenium,google-cloud-pubsub]
4042

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-e file:.[docker-compose,mysql,oracle,postgresql,selenium,google-cloud-pubsub,mongo,redis]
1+
-e file:.[docker-compose,mysql,oracle,postgresql,selenium,google-cloud-pubsub,mongo,redis,mssqlserver]
22
codecov
33
flake8
44
pytest

requirements/3.5.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ mccabe==0.6.1 # via flake8
3838
more-itertools==8.2.0 # via pytest
3939
packaging==20.1 # via pytest
4040
paramiko==2.7.1 # via docker
41+
pathlib2==2.3.5 # via pytest
4142
pluggy==0.13.1 # via pytest
4243
protobuf==3.11.3 # via google-api-core, googleapis-common-protos
4344
psycopg2-binary==2.8.4 # via testcontainers
@@ -50,6 +51,7 @@ pyflakes==2.1.1 # via flake8
5051
pymongo==3.10.1 # via testcontainers
5152
pymysql==0.9.3 # via testcontainers
5253
pynacl==1.3.0 # via paramiko
54+
pyodbc==4.0.30 # via testcontainers
5355
pyparsing==2.4.6 # via packaging
5456
pyrsistent==0.15.7 # via jsonschema
5557
pytest-cov==2.8.1 # via -r requirements.in
@@ -60,7 +62,7 @@ redis==3.4.1 # via testcontainers
6062
requests==2.23.0 # via codecov, docker, docker-compose, google-api-core
6163
rsa==4.0 # via google-auth
6264
selenium==3.141.0 # via testcontainers
63-
six==1.14.0 # via bcrypt, cryptography, docker, docker-compose, dockerpty, google-api-core, google-auth, grpcio, jsonschema, packaging, protobuf, pynacl, pyrsistent, websocket-client
65+
six==1.14.0 # via bcrypt, cryptography, docker, docker-compose, dockerpty, google-api-core, google-auth, grpcio, jsonschema, packaging, pathlib2, protobuf, pynacl, pyrsistent, websocket-client
6466
sqlalchemy==1.3.13 # via testcontainers
6567
texttable==1.6.2 # via docker-compose
6668
urllib3==1.25.8 # via requests, selenium

requirements/3.6.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pyflakes==2.1.1 # via flake8
5050
pymongo==3.10.1 # via testcontainers
5151
pymysql==0.9.3 # via testcontainers
5252
pynacl==1.3.0 # via paramiko
53+
pyodbc==4.0.30 # via testcontainers
5354
pyparsing==2.4.6 # via packaging
5455
pyrsistent==0.15.7 # via jsonschema
5556
pytest-cov==2.8.1 # via -r requirements.in

requirements/3.7.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pyflakes==2.1.1 # via flake8
5050
pymongo==3.10.1 # via testcontainers
5151
pymysql==0.9.3 # via testcontainers
5252
pynacl==1.3.0 # via paramiko
53+
pyodbc==4.0.30 # via testcontainers
5354
pyparsing==2.4.6 # via packaging
5455
pyrsistent==0.15.7 # via jsonschema
5556
pytest-cov==2.8.1 # via -r requirements.in

requirements/3.8.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pyflakes==2.1.1 # via flake8
4949
pymongo==3.10.1 # via testcontainers
5050
pymysql==0.9.3 # via testcontainers
5151
pynacl==1.3.0 # via paramiko
52+
pyodbc==4.0.30 # via testcontainers
5253
pyparsing==2.4.6 # via packaging
5354
pyrsistent==0.15.7 # via jsonschema
5455
pytest-cov==2.8.1 # via -r requirements.in

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
'selenium': ['selenium'],
5656
'google-cloud-pubsub': ['google-cloud-pubsub'],
5757
'mongo': ['pymongo'],
58-
'redis': ['redis']
58+
'redis': ['redis'],
59+
'mssqlserver': ['pyodbc']
5960
},
6061
long_description_content_type="text/markdown",
6162
long_description=long_description,

0 commit comments

Comments
 (0)