From 14aa9697f7fe103a010d3901fe72315ae8b7ce41 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 11 Dec 2017 10:43:37 +0100 Subject: [PATCH] Add the basic sqlalchemy code --- database.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 database.py diff --git a/database.py b/database.py new file mode 100644 index 0000000..8518c5a --- /dev/null +++ b/database.py @@ -0,0 +1,27 @@ +from sqlalchemy import Table, Column, BigInteger, Numeric, String, Text, MetaData, ForeignKey +import decimal + +# Create a metadata object containing info about the tables in the database +metadata = MetaData() + +# Metadata for the users table +# TODO: maybe add a 'credit' column +users = Table("users", metadata, + Column("telegram_user_id", BigInteger, primary_key=True), + Column("first_name", String, nullable=False), + Column("last_name", String), + Column("username", String)) + +# Metadata for the admins table +# TODO: add columns for all the possible permissions +admins = Table("admins", metadata, + Column("telegram_user_id", ForeignKey("users.telegram_user_id"), primary_key=True)) + +# Metadata for the products table +products = Table("products", metadata, + Column("product_name", String, primary_key=True), + Column("description", Text), + Column("price", Numeric(...))) + +#TODO: many things are still missing... +raise NotImplementedError() \ No newline at end of file