-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.py
36 lines (24 loc) · 938 Bytes
/
user.py
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
33
34
35
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
Base = declarative_base();
class User(Base):
__tablename__ = 'Users'
id=Column(Integer, primary_key=True)
username=Column(String, unique=True)
password=Column(String, unique=True)
engine = create_engine('sqlite:///Forum.sqlite')
Base.metadata.create_all(engine)
session = Session(bind=engine)
conn = engine.connect();
TBD1 = User(username='***', password='****');
TBD2 = User(username='***', password='****');
# session.add_all([Neil,Joe]);
# session.commit();
tables = engine.execute("SELECT * FROM sqlite_master WHERE TYPE='table'")
for index, table in enumerate(tables):
table_name = table[1]
print(f"The #{index} table in the database is called '{table_name}'.")
search = conn.execute('SELECT * FROM Users').fetchall();
print(search);