Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- conn = psycopg2.connect(host="194.182.74.138",
- dbname="vkbot_db",
- user="vkbot_user",
- password="vkbot_password")
- cursor = conn.cursor()
- BACKSLASH = '\n'
- def swearwords_fillng(file: str):
- with open(file, 'rt') as text_file:
- for line in text_file.readlines():
- print(line.strip('\n').lower())
- cursor.execute(f"""
- INSERT INTO public."Key Words"(
- word, word_type_choice)
- VALUES ('{line.strip(BACKSLASH).lower()}', 'SWR');
- """)
- conn.commit()
- def goodbyewords_fillng(file: str):
- with open(file, 'rt') as text_file:
- for line in text_file.readlines():
- print(line.strip('\n').lower())
- cursor.execute(f"""
- INSERT INTO public."Key Words"(
- word, word_type_choice)
- VALUES ('{line.strip(BACKSLASH).lower()}', 'GDB');
- """)
- conn.commit()
- def welcomewords_fillng(file: str):
- with open(file, 'rt') as text_file:
- for line in text_file.readlines():
- print(line.strip('\n').lower())
- cursor.execute(f"""
- INSERT INTO public."Key Words"(
- word, word_type_choice)
- VALUES ('{line.strip(BACKSLASH).lower()}', 'WLC');
- """)
- conn.commit()
- goodbyewords_fillng(file='additional_modules/goodbyewords.txt')
- swearwords_fillng(file='additional_modules/swearwords.txt')
- welcomewords_fillng(file='additional_modules/welcomewords.txt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement