all the project copy

This commit is contained in:
2026-07-16 12:27:06 +02:00
parent 926b7de75b
commit 568beef49a
631 changed files with 130346 additions and 0 deletions

42
api/connection.py Normal file
View File

@@ -0,0 +1,42 @@
from pathlib import Path
import sys
import psycopg2
ROOT_DIR = Path(__file__).resolve().parents[1]
CONN_DIR = ROOT_DIR / "conn"
if str(CONN_DIR) not in sys.path:
sys.path.insert(0, str(CONN_DIR))
import config
def conn():
try:
connection = psycopg2.connect(**config.POSTGRES_CONFIG)
return connection
# cursor = connection.cursor()
# postgres_insert_query = """ INSERT INTO mobile (ID, MODEL, PRICE) VALUES (%s,%s,%s)"""
# record_to_insert = (5, 'One Plus 6', 950)
# cursor.execute(postgres_insert_query, record_to_insert)
# connection.commit()
# count = cursor.rowcount
# print(count, "Record inserted successfully into mobile table")
except (Exception, psycopg2.Error) as error:
print("Failed to insert record into mobile table", error)
return False
# finally:
# # closing database connection.
# if connection:
# connection.cursor().close()
# connection.close()
# print("PostgreSQL connection is closed")