-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
51 lines (32 loc) · 1.12 KB
/
test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
from app import app, db
from models.user import UserModel
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import sessionmaker
def checkHttp():
BASE = "http://127.0.0.1:5000/"
app.app_context().push()
db.create_all()
response = requests.get(BASE + "user/kHYMghw6DgdfKfik")
# Print the response content and status code for debugging
print(response.json())
print("Response Status Code:", response.status_code)
def checkDB():
app.app_context().push()
db.create_all()
engine = create_engine('postgresql://liambrem:pass@localhost:5432/ft')
Session = sessionmaker(bind=engine)
session = Session()
metadata = MetaData()
metadata.reflect(bind=engine)
tableNames = metadata.tables.keys()
for table_name in tableNames:
table = metadata.tables[table_name]
print(f"Table: {table_name}")
for column in table.columns:
print(f" Column: {column.name} - Type: {column.type}")
checkHttp()
#print all entries from database
users = UserModel.query.all()
for user in users:
print(user.username)