diff options
author | Parker <contact@pkrm.dev> | 2024-06-24 16:24:09 -0500 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-06-24 16:24:09 -0500 |
commit | 5b92454760a8af14bd1031e72024946f868d1de6 (patch) | |
tree | f8384cbf0d142777d9bff341e13fd5882182908b /app/db.py | |
parent | 80a39d38bf829193c655a7320c86df2a3146db2a (diff) |
Major overhaul + Bare bones web UI
Diffstat (limited to 'app/db.py')
-rw-r--r-- | app/db.py | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/app/db.py b/app/db.py deleted file mode 100644 index 1750472..0000000 --- a/app/db.py +++ /dev/null @@ -1,37 +0,0 @@ -import sqlalchemy -import os - -try: - os.mkdir('data') -except FileExistsError: - pass -engine = sqlalchemy.create_engine('sqlite:///data/data.db') - - -def init_db(): - with engine.begin() as conn: - conn.execute(sqlalchemy.text( - ''' - CREATE TABLE IF NOT EXISTS keys ( - api_key, PRIMARY KEY (api_key) - ) - ''' - )) - conn.execute(sqlalchemy.text( - ''' - CREATE TABLE IF NOT EXISTS links ( - owner, link, redirect_link, expire_date, - FOREIGN KEY (owner) REFERENCES keys(api_key), PRIMARY KEY (link) - ) - ''' - )) - conn.execute(sqlalchemy.text( - ''' - CREATE TABLE IF NOT EXISTS records ( - owner, link, timestamp, ip, location, browser, os, user_agent, isp, - FOREIGN KEY (owner) REFERENCES links(owner), - FOREIGN KEY (link) REFERENCES links(link)) - ''' - )) - - conn.commit()
\ No newline at end of file |