Questions tagged [pygresql]
48
questions
0
votes
2
answers
52
views
How do I format parameters for PyGreSQL?
I am using PyGreSQL to execute queries against my DB. I need to insert the values to be matched at runtime, but the parameters are not being into the query correctly. If my query is:
SELECT *
FROM ...
1
vote
2
answers
2k
views
Making PyGreSQL to work in AWS Lambda (Python 3.9) to connect to a PostgreSQL instance
I struggled a bit to make PyGreSQL to work in AWS Lambda (Python 3.9) to connect to an Aurora PostgreSQL instance. Searching google and stack overflow didn't return any relevant results. Most of the ...
0
votes
1
answer
92
views
PyGreSQL upsert() Help Needed
I am using CentOS-6 with Python 3.8, PostgreSQL 12 and PyGreSQL 5.2.2.
With older versions, I had a function like the following. Back then an update raised an exception if the row didn't already ...
0
votes
1
answer
585
views
{InternalError}ERROR: Assert false - Invalid type: 705
based on https://pygresql.readthedocs.io/en/latest/contents/pg/adaptation.html
sql = "SELECT * FROM user_table WHERE login = %s AND passwd = %s"
db.query_formatted(sql, (login, passwd))....
1
vote
1
answer
116
views
PyGreSQL - Unable to Insert Data
I am using CentOS-6 with Python 3.8, PostgreSQL 12 and PyGreSQL 5.2.2. This is the error I get trying to insert data into my database.
>>> db.insert('settings', None, **data)
Traceback (most ...
0
votes
1
answer
3k
views
ModuleNotFoundError: No module named 'pg'
After trying to use pg library in Python as just as
import pg
I get this error message:
Traceback (most recent call last):
File "<input>", line 1, in <module>
module = ...
0
votes
1
answer
617
views
PyGreSQL AWS Glue Python
I'm trying to use the PyGreSQL package in AWS Glue with a Python job.
I have uploaded to a S3 bucket the wheel file from here:
https://pypi.org/project/PyGreSQL/#files
the 3.6 for x64
then in the job ...
3
votes
1
answer
3k
views
pygresql copy_from gives a relation does not exist error
I have the following code
pg_con = conns.con_to_pg()
cur = pg_con.cursor()
with open('up_md.csv', 'r') as f:
next(f) # Skip the header row.
tbl = 'bidba.upmeta'
cur.copy_from(f, tbl, '...
1
vote
1
answer
1k
views
Is PygreSQL available on AWS Glue Spark Jobs?
I tried using PygreSQL modules
import pg
import pgdb
but it says the modules were not found when running on AWS Glue Spark.
Their Developer Guide, https://docs.aws.amazon.com/glue/latest/dg/glue-dg....
0
votes
2
answers
161
views
How to execute parallel queries with PyGreSQL?
I am trying to run multiple queries in parallel with PyGreSQL and multiprocessing, but below code hangs without returning:
from pg import DB
from multiprocessing import Pool
from functools import ...
3
votes
1
answer
72
views
PyGreSQL is returning unexpected result for a one column select statement
I have the following PostgreSQL database table:
TABLE session_monitor
(
id int,
customer_name varchar(150)
)
When I am running the following code:
seq = pg_cur.execute("SELECT id ,...
0
votes
0
answers
279
views
PyGreSQL/pg hangs when connecting to DB over SSH tunnel
In my Python script, I want to be able to connect to a Postgres DB via an SSH tunnel.
I'm using sshtunnel package to create a tunnel, and using PyGreSQL to connect to the DB.
When I try to establish ...
1
vote
2
answers
335
views
How do I catch specific exceptions from pygresql?
I'm trying to improve my error handling, Particularly I would like to handle IntegrityError exceptions from pygresql.
I'm getting the error "NameError: name 'IntegrityError' is not defined" so I need ...
0
votes
2
answers
347
views
AWS Glue Python Shell script timing out
I am trying to connect to and read an on-premise data source using an AWS Glue Python Shell job. I am using Pygresql (which comes bundled on Glue) and Pandas. Everything works locally.
But when I ...
2
votes
2
answers
1k
views
Execute SQL select in statement using pygresql(pg module)
I am working on a python script to connect to postgress databases using pygresql module. Below is the code
I am trying to run the query by passing tuple as parameter.
query looks like this:
select ...
1
vote
2
answers
465
views
Using json_to_record() to add a new row to a table PostgresSQL
I have table_A with two columns:
create table table_a(id int, data json);
A row could be:
insert into table_a values
(1, '{"name": "kate", "cellphone": "000-000-0000", "address": "some text here"}')...
1
vote
1
answer
1k
views
Unable to install PyGreSql on Centos
I'm doing the following to install PyGreSql on Centos:
sudo pip3 install pygresql
But I get the following error:
Collecting PyGreSQL
Using cached https://files.pythonhosted.org/packages/4a/65/...
0
votes
1
answer
418
views
how does a Python api database connection work?
I am starting to try an work with databases using Python. I am trying to understand the process when I connect to a database and get some data out of it.
I think it works like this: The Python code ...
2
votes
1
answer
4k
views
Inserting None value into Date column from python to PostgreSQL database using PygreSQL v5.0.6
I am struggling to insert None values into the date column of a PostgreSQL database from python using PygreSQL v5.0.6.
Some code:
def _update_traits_db(self, code, date_start, date_end, unit):
...
0
votes
0
answers
1k
views
pygresql - insufficient data in "T" message
I've caught a problem I can't explain using pygresql for python. This is a simple SELECT query and as far as I can tell the only query that has the problem in the whole script.
Exception in thread ...
1
vote
0
answers
538
views
Error with using PyGreSQL. pg.DatabaseError: Last query did not return tuples
I use pgdb(PyGreSQL) in my project to connect to the working DB.
I wrote generator to fetch rows with the pagination from huge tables.
# DbHelper.py
...
def GetMultipleRowsGenerator(self, query, ...
1
vote
1
answer
885
views
Command "python setup.py egg_info" failed with error code 1 pygresql
I'm not able to install pygresql. When I run pip install, I get this:
(postgresql) Matts-MacBook-Pro:~ mattspeck$ pip install pygresql
Collecting pygresql
Using cached PyGreSQL-5.0.4.tar.gz
...
2
votes
0
answers
232
views
Using PyGreSQL: 'bytes' object has no attribute 'encode'
I'm trying to import PyGreSQL in Python. I've successfully installed it with pip, and also have GLFW3 installed, but I run into the following error when I import
>>> import pg
Traceback (...
1
vote
1
answer
212
views
Python - convert pgqueryobject to string
Prelude:
Python version: 2.7.9
Pygresql version: 4.0
Problem:
I am trying to check if a sub string exists within a pgqueryobject using python.
Basically I have this in terms of code:
import pg
...
4
votes
1
answer
22k
views
error : command 'gcc' failed with exit status 1 while installing pygresql
I am trying to install the pygresql package using "pip install pygresql" but I get the error : command 'gcc' failed with exit status 1
I've tried a lot of thing but I still do not understand why it is ...
3
votes
1
answer
4k
views
Get lazy but reusable cursor with Psycopg2
I saw in the docs that you need to use server-side ("named") cursors to avoid loading all results into memory at once. But then I found that server-side cursors aren't reusable. You can only do a ...
1
vote
1
answer
1k
views
How to install PyGreSQL using Virtualenv on Mac OS Sierra
I'm configuring a virtualenv to work with a legacy webservices application developed on python using flask microframework and PostgreSQLdatabase, this application use PyGreSQL 5.0.3 as a dependency to ...
0
votes
2
answers
7k
views
Python: Installing pygresql
I am trying to install PyGreSQL module on my computer using pip. It shows this message:
Collecting pygresql
Using cached PyGreSQL-5.0.3-cp35-cp35m-win_amd64.whl
Installing collected ...
0
votes
2
answers
122
views
How to update Python PygreSQL package on Linux Debian?
I have Linux Debian installed.
In debian repository the newest stable version of PygreSQL is 4.0
The newest version of PygreSQL is 5.0.2 but I don't see debian in thier site:
http://www.pygresql.org/...
0
votes
1
answer
347
views
copy LONGTEXT from MySQL to CITEXT in PostgreSQL using Python
I have data in MySQL table which I want to copy to a PostgreSQL table.
Everything works except when the MySQL contains a string with " and/or '
For example:
The data in MySQL:
When I run my code I ...
2
votes
3
answers
5k
views
Import Errror for python pg module
I am having trouble using the pg module in my code. I've installed it using pip. But when I go to run it I get the following error:
Traceback (most recent call last):
File "Contract_gen.py", line 2,...
1
vote
1
answer
110
views
PyGreSQL Run SQL interactively
I have a GreenPlum database, and I'm trying to create several external tables.
I'm using the PyGreSQL package to interface with the database.
However, I can't escape \i (or \dt, \du, \dv).
db....
2
votes
1
answer
613
views
clang error when installing pygresql under Mac OS
I was trying to install PyGreSQL under Mac OS X(10.11.3), but the same clang error occurs when installing from pip and source.
$ python3 setup.py install
running install
running bdist_egg
running ...
1
vote
2
answers
10k
views
How to iterate over Postgresql rows in a Python script?
I'm writing a script which selects from a DB table and iterates over the rows.
In MySQL I would do:
import MySQLdb
db_mysql=MySQLdb.Connect(user=...,passwd=...,db=..., host=...)
cur = db_mysql....
2
votes
1
answer
763
views
Failture installing PyGreSQL with pip [duplicate]
I am currently trying to install PyGreSQL using pip install PyGreSQL, however, when I run the command I get the following error:
Could not import setuptools which is required to install from a ...
0
votes
2
answers
988
views
OperationalError: not enough arguments for format string
I'm running the following code:
#converts strings that are ints to int.
for i,x in enumerate(values):
try:
values[i] = int(x)
except:
pass
# Fills values with NULLs if needed
...
0
votes
1
answer
132
views
How to not have pgdb add quotes
I'm doing an SQL insterface, and I'm having a problem with string formatting. What I want to do is an SQL INSERT INTO table_name statement. When I do it now, using parameterized instertion, I get ...
7
votes
2
answers
9k
views
Installing pgdb: pg_config tool is not available
So here is my goal: To get a .py file that imports pgdb, to run.
For this, as far as I have understood, I need PygreSql.
I have both postgresql 9.4.4 and python 2.7.9 installed (Postgresql with ...
4
votes
3
answers
9k
views
ver.2 PyGreSQL ERROR: from _pg import * ImportError: DLL load failed: The specified module could not be found
I have the same problem that was discussed here, but I haven't credit to comment an answer so I start new question.
I have in PATH way to libpq.dll (C:\PostgreSql\lib) but it doesn't solve this ...
0
votes
1
answer
177
views
AttributeError: get_tables
What is the problem of this code? Should show a list of tables
import pg
con = pg.connect(dbname='xxx', host='xxxx', user='xxx')
pgqueryset = con.get_tables()
Traceback (most recent call last):
...
0
votes
2
answers
1k
views
python pg module error messages
pg module in python for interacting with postgres is not giving any error message for DML queries.
Is there any alternative to pg module which gives meaningful error messages.
>>>import pg
...
1
vote
2
answers
2k
views
How to use auto increase primary key using PyGreSQL and PostgreSQL
I have a table in my PostgreSQL:
CREATE SEQUENCE dember_id_seq INCREMENT BY 1 MINVALUE 1 START 1;
CREATE TABLE dember (id INT NOT NULL, did VARCHAR(255) DEFAULT NULL, dnix VARCHAR(255) DEFAULT NULL, ...
0
votes
2
answers
1k
views
How to install pygresql in virtualenv?
when I try to install it via pip, or easy_install, it gives me error:
OSError: [Errno 2] No such file or directory: '/usr/include/pgsql/server'
How should I do this correctly?
2
votes
4
answers
2k
views
Using Python/PyGreSQL, how can I efficiently handle a large result set?
I have a query result set of ~ 9-million rows.
I need to do some processing for each row, and the code currently does this:
query = conn.query(sql)
results = query.getresult()
for row in results:
...
2
votes
2
answers
4k
views
Why can't I import pg.py?
>>> import pg
Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
import pg
File "C:\EPD\lib\site-packages\pg.py", line 21, in <module>
...
0
votes
1
answer
2k
views
python sql interval
With PostgreSQL, one of my tables has an 'interval' column, values of which I would like to extract as something I can manipulate (datetime.timedelta?); however I am using PyGreSQL which seems to be ...
0
votes
1
answer
349
views
PyGreSQL NULLs for integer field
I am trying to insert some rows into a table which has a field of integers, which can be NULL:
cur.execute("INSERT INTO mytable (id, priority) VALUES (%(id)d, %(priority)d)", \
{'id': id, ...
1
vote
3
answers
3k
views
pygresql - insert and return serial
I'm using PyGreSQL to access my DB. In the use-case I'm currently working on; I am trying to insert a record into a table and return the last rowid... aka the value that the DB created for my ID field:...