-
-
Save ansh/feb7147c9935b0986fa1e2e3111c53a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import psycopg2 | |
import yaml | |
import zlib | |
import base64 | |
import ctypes | |
import gzip | |
import json | |
from struct import * | |
def connect(): | |
print('Connecting to the PostgreSQL database...') | |
conn = psycopg2.connect( | |
host="localhost", | |
database="postgres", | |
user="postgres", | |
password="6174", | |
port="5432") | |
return conn | |
def add_origin(file): | |
cur = connect().cursor() | |
print("executing db stuff") | |
cur.execute("SELECT content FROM question WHERE id=1") | |
compressed_content = bytes(cur.fetchone()[0]) | |
print(compressed_content) | |
print(compressed_content.decode()) | |
if __name__ == '__main__': | |
file_name = sys.argv[1] | |
print(file_name) | |
with open(f"./{file_name}") as file: | |
file_obj = yaml.load(file, Loader=yaml.FullLoader) | |
print(file_obj) | |
add_origin(file_obj) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment