From 563d5019468d3c5c9eea5dc5285996516fca2bdc Mon Sep 17 00:00:00 2001 From: Faholan <62927863+Faholan@users.noreply.github.com> Date: Mon, 31 Aug 2020 10:44:56 +0200 Subject: [PATCH] command.sql file + runme.py --- command.sql | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ runme.py | 31 +++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 command.sql create mode 100644 runme.py diff --git a/command.sql b/command.sql new file mode 100644 index 0000000..b86cec1 --- /dev/null +++ b/command.sql @@ -0,0 +1,71 @@ +CREATE TABLE blacklist ( + guild_ids bigint[] NOT NULL, + user_ids bigint[] NOT NULL +); + + +ALTER TABLE blacklist OWNER TO {owner}; + +CREATE TABLE dungeon ( + guild_id bigint NOT NULL, + minimum_days integer NOT NULL, + dungeon_role_id bigint NOT NULL, + mod_status integer NOT NULL, + announcement_channel bigint NOT NULL, + mod_message text NOT NULL, + bypass_list bigint[] NOT NULL, + dungeon_status boolean NOT NULL +); + + +ALTER TABLE dungeon ADD CONSTRAINT unique_dungeon + UNIQUE (guild_id); + +ALTER TABLE dungeon OWNER TO {owner}; + +CREATE TABLE lock ( + guild_id bigint NOT NULL, + lock_state integer, + link_state integer +); + + +ALTER TABLE public.lock ALTER lock_state SET DEFAULT 0; +ALTER TABLE public.lock ALTER link_state SET DEFAULT 0; + +ALTER TABLE lock ADD CONSTRAINT lock_unique + UNIQUE (guild_id); + +ALTER TABLE lock OWNER TO {owner}; + +CREATE TABLE prefixes ( + ctx_id bigint NOT NULL, + prefix text NOT NULL +); + + +ALTER TABLE prefixes ADD CONSTRAINT prefixes_unique + UNIQUE (ctx_id); + +ALTER TABLE prefixes OWNER TO {owner}; + +CREATE TABLE smartreact ( + guild_id bigint NOT NULL +); + + +ALTER TABLE smartreact ADD CONSTRAINT unique_smartreact + UNIQUE (guild_id); + +ALTER TABLE smartreact OWNER TO {owner}; + +CREATE TABLE subscribe ( + guild_id bigint NOT NULL, + role_id bigint NOT NULL +); + + +ALTER TABLE subscribe ADD CONSTRAINT unique_subscribe + UNIQUE (guild_id); + +ALTER TABLE subscribe OWNER TO {owner}; diff --git a/runme.py b/runme.py new file mode 100644 index 0000000..676907f --- /dev/null +++ b/runme.py @@ -0,0 +1,31 @@ +import asyncio + +import asyncpg + + +async def main(): + """Create all the tables.""" + username = input( + "Please enter the username of the PostgreSQL account: " + ) + password = input( + "Please enter the password of the PostgreSQL account: " + ) + database = input( + "Please enter the name of the database: " + ) + con = await asyncpg.connect( + host="127.0.0.1", + user=username, + password=password, + database=database, + ) + file = open("command.sql") + statement = file.read() + file.close() + await con.execute( + statement.format(owner=username) + ) + +if __name__ == "__main__": + asyncio.run(main())