-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathclassSqlAlchemy.py
More file actions
31 lines (25 loc) · 845 Bytes
/
classSqlAlchemy.py
File metadata and controls
31 lines (25 loc) · 845 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
from sqlalchemy import create_engine
import pandas as pd
class SqlalchemyOop:
def return_engine(self, connection_string):
engine = create_engine(connection_string)
connection = engine.connect()
return connection
def database_connection(self, connection):
connection = self.engine.connect()
def select_query(self, query):
data = pd.read_sql(query, self.connection)
return data
def get_tables(self):
return self.engine.table_names()
# independant
@staticmethod
def df(data):
df = pd.DataFrame(data)
return df
def get_duplicates(self):
z = self.df
y = z.copy()
analysis_abc = pd.concat([z, y])
analysis_abc.to_sql('analysis_abc', con=self.engine)
self.connection.close()