-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuniversal.py
More file actions
executable file
·32 lines (28 loc) · 1.01 KB
/
universal.py
File metadata and controls
executable file
·32 lines (28 loc) · 1.01 KB
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
32
import sqlite3
import sqlalchemy
from sqlalchemy import create_engine, ForeignKey
from sqlalchemy import Column, Date, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from tabulate import tabulate
def printTable(dbSession, table):
cols = dbSession.connection().execute("PRAGMA table_info({})".format(table))
headers = []
for col in cols:
headers.append(col[1])
output = []
rfidList = dbSession.connection().execute("SELECT * FROM {}".format(table))
for row in rfidList:
item = []
for i in range(len(row)):
item.append(row[i])
output.append(item)
print(tabulate(output, headers=headers, tablefmt='rst'))
print('\n')
def establishConnection(dbName):
engine = create_engine('sqlite:///databases/{}'.format(dbName))
Session = sessionmaker()
Session.configure(bind=engine)
return Session()
def pause():
input('Press enter to continue...\n')