Skip to content

Commit

Permalink
Removal: Remove support for MSSQL
Browse files Browse the repository at this point in the history
SQL Server support is removed because pymssql is not supported anymore.
Check #72 for issues in installing 2.x versions of the library in 3.8.1.
Even with Cython, the library does not install due to build issues.

Fix #29
  • Loading branch information
Rajat Venkatesh authored and vrajat committed Feb 18, 2020
1 parent bc4fc65 commit 2ddd4c2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 60 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:

# Download and cache dependencies
- restore_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
key: deps9-{{ checksum "Pipfile.lock" }}

- run:
name: install dependencies
Expand All @@ -71,7 +71,7 @@ jobs:
pipenv run python -m spacy download en_core_web_sm
- save_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
key: deps9-{{ checksum "Pipfile.lock" }}
paths:
- ".venv"

Expand All @@ -97,14 +97,14 @@ jobs:
steps:
- checkout
- restore_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
key: deps9-{{ checksum "Pipfile.lock" }}
- run:
name: install dependencies
command: |
sudo pip install pipenv
pipenv install --dev
- save_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
key: deps9-{{ checksum "Pipfile.lock" }}
paths:
- ".venv"

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ PiiCatcher supports the following databases:
2. **MySQL** 5.6 or greater
3. **PostgreSQL** 9.4 or greater
4. **AWS Redshift**
5. **SQL Server**
6. **Oracle**
7. **AWS Glue/AWS Athena**
5. **Oracle**
6. **AWS Glue/AWS Athena**

## Documentation

Expand Down
45 changes: 0 additions & 45 deletions piicatcher/explorer/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import click
import pymysql
import psycopg2
import pymssql
import cx_Oracle

import logging
Expand Down Expand Up @@ -219,50 +218,6 @@ def _get_sample_query(cls, schema_name, table_name, column_list):
)


class MSSQLExplorer(RelDbExplorer):
_catalog_query = """
SELECT
TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
DATA_TYPE LIKE '%char%'
ORDER BY TABLE_SCHEMA, table_name, ordinal_position
"""

_sample_query_template = "SELECT TOP 10 * FROM {schema_name}.{table_name} TABLESAMPLE (1000 ROWS)"

def __init__(self, ns):
super(MSSQLExplorer, self).__init__(ns)
self._mssql_database = self._mssql_database if ns.database is None else ns.database

@property
def default_database(self):
return "public"

@property
def default_port(self):
return 1433

def _open_connection(self):
return pymssql.connect(host=self.host,
port=self.port,
user=self.user,
password=self.password,
database=self._mssql_database)

def _get_catalog_query(self):
return self._catalog_query

@classmethod
def _get_sample_query(cls, schema_name, table_name, column_list):
return cls._sample_query_template.format(
column_list=",".join([col.get_name() for col in column_list]),
schema_name=schema_name.get_name(),
table_name=table_name.get_name()
)


class OracleExplorer(RelDbExplorer):
_catalog_query = """
SELECT
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ commonregex
spacy
tableprint
pymysql
pymssql<3.0
cx_Oracle
psycopg2-binary
cryptography
Expand Down
8 changes: 1 addition & 7 deletions tests/test_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest

from piicatcher.explorer.databases import MySQLExplorer, PostgreSQLExplorer, OracleExplorer, \
MSSQLExplorer, RelDbExplorer
RelDbExplorer
from piicatcher.explorer.sqlite import SqliteExplorer
from piicatcher.explorer.metadata import Schema, Table, Column
from piicatcher.piitypes import PiiTypes
Expand Down Expand Up @@ -360,12 +360,6 @@ def test_mysql(self):
self.schema.get_children()[0],
self.schema.get_children()[0].get_children()))

def test_mssql(self):
self.assertEqual("select c1,c2 from testSchema.t1",
MSSQLExplorer._get_select_query(self.schema,
self.schema.get_children()[0],
self.schema.get_children()[0].get_children()))


class TestDispatcher(TestCase):

Expand Down

0 comments on commit 2ddd4c2

Please sign in to comment.