" enter which operation to perform\n0.display many\n1.display one\2.insert one\n3.insert many\n4.delete one\n5.delete many\n6.update one \n7. update many"))
# create a db connection
db=db_connect()
# create a collection
collection=db['students_collection']
ifchoice==0:
finding_many(collection)
ifchoice==1:
finding_one(collection)
ifchoice==2:
inserting_one(collection)
ifchoice==3:
inserting_many(collection)
ifchoice==4:
delete_one_document(collection)
ifchoice==5:
delete_many_document(collection)
ifchoice==6:
update_one_document(collection)
ifchoice==7:
update_many_document(collection)
exceptExceptionase:
print("Error-",e)
finally:
print("end")
defcrud_operations_postgresql():
defcrud_operations_postgresql():
try:
try:
postgresql_connection=connect_db()
db_postgres_class=PostgresStart()
cursor=postgresql_connection.cursor()
create_result=db_postgres_class.post_create()
# checking if the table exists
ifnotcreate_result:
cursor.execute(f"SELECT * FROM information_schema.tables WHERE table_name = 'tbl_company'")