balance-application/generate.py

43 lines
668 B
Python
Raw Normal View History

2024-09-10 04:14:09 +00:00
import psycopg2
from util.config import conn_param
def __main__():
conn = psycopg2.connect(conn_param)
cur = conn.cursor()
2024-09-10 05:20:11 +00:00
cur.execute(
"""
create table account(
name varchar(25),
username varchar(25) primary key,
password varchar(50) not null,
salt varchar(50)
unique(username)
);
"""
)
2024-09-10 04:14:09 +00:00
cur.execute(
"""
create table balset(
id serial primary key,
2024-09-10 05:20:11 +00:00
uid varchar(25) not null,
2024-09-10 04:14:09 +00:00
name varchar(50),
date bigint,
price bigint,
2024-09-10 05:20:11 +00:00
memo varchar(300),
constraint FK_Account_ID
foreign key (uid)
references account(username)
on delete CASCADE
2024-09-10 04:14:09 +00:00
);
"""
)
conn.commit()
cur.close()
conn.close()
__main__()