File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
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 ()
You can’t perform that action at this time.
0 commit comments