remote-postgres 1.2.5

Creator: railscoder56

Last updated:

0 purchases

remote-postgres 1.2.5 Image
remote-postgres 1.2.5 Images

Languages

Categories

Add to Cart

Description:

remotepostgres 1.2.5

# RemotePostgresRemotePostgres is a way to easily access a remote Postgres database and perform queries, including SELECT and INSERT operationsSee below for examples of how to use```pythonfrom remote_postgres import RemotePostgresimport mysecretsdb = RemotePostgres(f'postgres://{mysecrets.pg_user}:{mysecrets.pg_password}@{mysecrets.pg_host}:{mysecrets.pg_port}/{mysecrets.pg_database}')``````pythondb.get_counts()``` [{'tmp_1347844423': 0}, {'Employee': 0}, {'tmp_1170648801': 0}]```pythondb.con.cursor().execute("""CREATE TABLE "Shipper" ("Id" INTEGER, "CompanyName" TEXT, "Phone" TEXT) """)``````pythonnew_records = [{'Id': 1, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'}, {'Id': 2, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'}, {'Id': 3, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}, {'Id': 4, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'}, {'Id': 5, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'}, {'Id': 6, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}]``````pythondb.insert('Shipper', new_records)``````pythondb.select('SELECT * FROM "Shipper"')``` [{'Id': 1, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'}, {'Id': 2, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'}, {'Id': 3, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}, {'Id': 4, 'CompanyName': 'Speedy Express', 'Phone': '(503) 555-9831'}, {'Id': 5, 'CompanyName': 'United Package', 'Phone': '(503) 555-3199'}, {'Id': 6, 'CompanyName': 'Federal Shipping', 'Phone': '(503) 555-9931'}]```pythoncur = db.con.cursor()cur.execute("""DELETE FROM "Shipper" WHERE "Id" > 3""")db.con.commit()``````pythondb.generate_create_table('Shipper', new_records)``` 'CREATE TABLE "Shipper" ("Id" TEXT, "CompanyName" TEXT, "Phone" TEXT)'```pythondb.con.cursor().execute("""DROP TABLE "Shipper" """)db.con.commit()``````pythondel db # Close the connection```

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.