Questions tagged [pg8000]

pg8000 is one of many Pure-Python PostgreSQL interfaces for the Python programming language.

pg8000 is one of many PostgreSQL interfaces for the Python programming language. It is written entirely in and does not rely on any external libraries (such as a compiled python module, or ’s library). It is DB-API 2.0 compatible Pure-Python interface to the PostgreSQL database engine.

pg8000’s name comes from the belief that it is probably about the 8000th PostgreSQL interface for Python. pg8000 is distributed under the terms of a modified BSD license.

PLease use this tag if your query is related to the use of pg8000 or its implementation.

62 questions
22
votes
8 answers

AttributeError: 'UUID' object has no attribute 'replace' when using backend-agnostic GUID type

I want to have a primary key id with type uuid in a Postgresql database using SQLAlchemy 1.1.5, connecting to the database with the pg8000 adapter. I used the Backend-agnostic GUID Type recipe from the SQLAlchemy documentation. When I want to insert…
The Oracle
  • 2,373
  • 3
  • 26
  • 44
14
votes
2 answers

How do I connect to Postgresql using SSL from SqlAchemy+pg8000?

Connecting to postgres via pg8000 from SqlAlchemy worked fine until I enabled SSL on postgres. db = create_engine('postgresql+pg8000://user:pass@hostname/dbname', echo=True).connect() Now it seems to fail with: File…
sorin
  • 161,544
  • 178
  • 535
  • 806
10
votes
6 answers

Passing param to DB .execute for WHERE IN... INT list

With Python's DB API spec you can pass an argument of parameters to the execute() method. Part of my statement is a WHERE IN clause and I've been using a tuple to populate the IN. For example: params = ((3, 2, 1), ) stmt = "SELECT * FROM table WHERE…
John Giotta
  • 16,432
  • 7
  • 52
  • 82
8
votes
2 answers

Using % wildcard with pg8000

I have a query similar to below: def connection(): pcon = pg8000.connect(host='host', port=1234, user='user', password='password', database = 'database') return pcon, pcon.cursor() pcon, pcur = connection() query = """ SELECT * FROM db…
Abi
  • 347
  • 5
  • 14
4
votes
1 answer

Sql Alchemy Insert Statement failing to insert, but no error

I am attempting to execute a raw sql insert statement in Sqlalchemy, SQL Alchemy throws no errors when the constructed insert statement is executed but the lines do not appear in the database. As far as I can tell, it isn't a syntax error (see no…
4
votes
3 answers

sqlalchemy ORM call fails with TypeError: expected bytes, str found

I am making the following (relatively) simple call in a bit of code I have written: pickups = session.query(Pickup).filter(Pickup.firebase_run_id == run_id).all() I have two sets of integration tests over this code, one that runs locally and uses…
Aleksey Bilogur
  • 3,686
  • 3
  • 30
  • 57
4
votes
0 answers

Using PostgreSQL with App Engine Standard

I trying to use postgres on app engine standard with python2.7 environment. I use sqlalchemy + pg8000 for connection, connection string looks like: postgresql+pg8000://user:password@/dbname?unix_sock=/cloudsql/project:us-central1:db It works on…
R.Arkhipov
  • 235
  • 1
  • 2
  • 5
4
votes
1 answer

Python/pg8000 WHERE IN statement

What is the correct method to have the tuple (names) be available via %s in the SQL statement? names = ('David', 'Isaac') sql = 'SELECT * from names WHERE name IN %s' cur.execute(sql,(names,)) The response in…
Tsachi
  • 57
  • 6
4
votes
3 answers

PostgreSQL with pg8000 - INSERT results from an SQL to another table

I am trying to copy rows form a PostgreSQL table to another one, using pg8000 driver for Python. This is the code: import pg8000 conn = pg8000.connect(user="postgres", password="XXXXX",database="test") cursor = conn.cursor() cursor.execute("SELECT *…
user1680859
  • 1,160
  • 2
  • 24
  • 40
3
votes
2 answers

Error installing cloud-sql-python-connector[pg8000] in Python 3.7

I am trying to connect to a Cloud SQL postgresql instance through python 3.7 from my local machine. I am following the guide from the README cloud-sql-python-connector. There it says to pip install the necessary module with the following command,…
3
votes
1 answer

GCP deploy db connection error: Can't create a connection to host

I am trying to deploy my flask app to GCP. However my db connection is not working. I already try different methods, but anything worked. I also setup db connection locally and I was able to write information on the Google SQL, but when I deploy the…
3
votes
0 answers

Cannot connect to AWS RDS Postgres with pg8000 but good with psycopg2

friends, I'm trying to connect to a Postgres instance in AWS RDS from python script running in an EC2 machine. It's working well with psycopg2/sqlalchemy as from sqlalchemy import create_engine import psycopg2 db_string =…
Winter JJJ
  • 31
  • 3
3
votes
1 answer

postgres pg8000 create database

I am trying to create a database with pg8000 driver of postgressql , but unable to create. Creating a db manually and then connecting to it works fine with me, but i need to create db with my code. I am getting error…
tec_abhi
  • 85
  • 9
3
votes
1 answer

Django pg8000 integration

I want to create a Django project with DB PostgreSQL backend as much as possible platform-independent. I know that default Django Postgresql driver is platform-dependent psycopg. I saw this answer displaying DB-API compatibility. My questions to…
lospejos
  • 1,976
  • 3
  • 19
  • 35
2
votes
2 answers

SQL Alchemy with PG8000 exception in IN query: invalid input syntax for type integer: "{2,3,5,6,7}"

cursor.execute(text("SELECT * FROM pnl WHERE type IN (:types)")) Works. The Following tests: cursor.execute(text("SELECT * FROM pnl WHERE type IN (:types)"), types=[2, 3, 5, 6, 7]) cursor.execute(text("SELECT * FROM pnl WHERE type IN (:types)"),…
Andreas
  • 539
  • 1
  • 5
  • 13
1
2 3 4 5