Skip to content

Commit 71d8639

Browse files
author
Pietro Giuffrida
committed
main.py example of usage
1 parent 9befe55 commit 71d8639

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

main.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
from sqlantipathy import MssqlAntipathy
5+
import pandas as pd
6+
7+
if __name__ == '__main__':
8+
9+
sql = MssqlAntipathy(
10+
hostname="sql_hostname",
11+
user="sql_user",
12+
pwd="sql_pwd",
13+
driver="sql_driver_name"
14+
)
15+
16+
sql.connect()
17+
18+
database_list = sql.show_databases()
19+
20+
sql.use_database("mydb")
21+
mydb_tables = sql.show_tables()
22+
23+
qry = """SELECT TOP 100 * FROM TABLENAME"""
24+
data = sql.retrieve("sql_input_db", qry)
25+
26+
list_of_dict = sql.retrieve("sql_input_db", qry)
27+
df = pd.DataFrame(list_of_dict)
28+
29+
sql.close_connection()
30+
31+
# A lot of code after...
32+
33+
sql.connect()
34+
sql.cursor.execute("""A SIMPLE QUERY""")
35+
raw_data = sql.cursor.fetchall()

0 commit comments

Comments
 (0)