Skip to content

Commit 90208a1

Browse files
author
Pietro Giuffrida
committed
branch sviluppo altri db
1 parent d9ccde5 commit 90208a1

13 files changed

+75
-3
lines changed

.gitignore

100755100644
File mode changed.

docs/Makefile

100755100644
File mode changed.

docs/make.bat

100755100644
File mode changed.

docs/source/conf.py

100755100644
File mode changed.

docs/source/index.rst

100755100644
File mode changed.

docs/source/modules.rst

100755100644
File mode changed.

docs/source/mssqlantipathy.rst

100755100644
File mode changed.

requirements.txt

100755100644
+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
mysql-connector-python
2+
cx_Oracle
13
numpy
24
pyodbc

setup.py

100755100644
File mode changed.

sqlantipathy/__init__.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
import pyodbc
5+
import logging
6+
7+
logger = logging.getLogger(__name__)
8+
logger.setLevel("DEBUG")
9+
10+
11+
def make_connection_string():
12+
return ""
13+
14+
15+
class SqlAntipathy:
16+
17+
insert_statement = """INSERT INTO {0} ({1}) VALUES ({2})"""
18+
19+
def __init__(self):
20+
self.connection_string = make_connection_string()
21+
self.connection = self.open_connection()
22+
self.cursor = self.open_cursor()
23+
24+
def open_connection(self):
25+
"""Apre la connessione al server MSSQL
26+
27+
Raises:
28+
ConnectionError: Restituisce errore se la connessione fallisce
29+
30+
Returns:
31+
str: Accesso al Server
32+
"""
33+
try:
34+
logger.debug("Tring to connect")
35+
connection = pyodbc.connect(self.connection_string, timeout=self.timeout)
36+
except:
37+
logger.error("COULD NOT PERFORM CONNECTION TO DB")
38+
logger.exception("")
39+
raise ConnectionError("Connection failed!")
40+
return connection
41+
42+
def open_cursor(self):
43+
"""Accesso al cursore del server MSSQL"""
44+
logger.debug("Opening cursor")
45+
return self.connection.cursor()
46+
47+
def use_database(self, dbname):
48+
"""Permette l'accesso a un database all'interno del server MSSQL
49+
50+
Args:
51+
dbname (str): Nome del database a cui si desidera accedere
52+
"""
53+
self.cursor.execute("USE {}".format(dbname))
54+
55+
def retrieve(self):
56+
pass
57+
58+
def insert_one(self):
59+
pass
60+
61+
def insert_many(self):
62+
pass
63+
64+
def bulk_insertion(self):
65+
pass
66+
67+
def commit(self):
68+
pass
69+
70+
def close_connection(self):
71+
"""Chiude la connessione al server MSSQL"""
72+
logger.debug("Closing connection")
73+
self.connection.close()

sqlantipathy/mssqlantipathy.py

100755100644
File mode changed.

sqlantipathy/mysqlantipathy.py

100755100644
File mode changed.

sqlantipathy/oracleantipathy.py

100755100644
-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
import base64
44
from time import sleep
55
from collections import Counter
6-
import os
76
import re
8-
import json
97
import cx_Oracle as mdb
108
import os
119
import csv
12-
# import fiona
1310
import logging
1411
import numpy as np
1512

0 commit comments

Comments
 (0)