Linked Questions

249 votes
21 answers
284k views

I need to insert multiple rows with one query (number of rows is not constant), so I need to execute query like this one: INSERT INTO t (a, b) VALUES (1, 2), (3, 4), (5, 6); The only way I know is ...
Sergey Fedoseev's user avatar
225 votes
13 answers
346k views

Is there any way to get SQLAlchemy to do a bulk insert rather than inserting each individual object. i.e., doing: INSERT INTO `foo` (`bar`) VALUES (1), (2), (3) rather than: INSERT INTO `foo` (`bar`...
Nick Holden's user avatar
  • 3,819
77 votes
4 answers
109k views

What's the best way to make psycopg2 pass parameterized queries to PostgreSQL? I don't want to write my own escpaing mechanisms or adapters and the psycopg2 source code and examples are difficult to ...
jeffcook2150's user avatar
  • 4,256
16 votes
2 answers
14k views

I need to efficiently insert about 500k (give or take 100k) rows of data into my PostgreSQL database. After a generous amount of google-ing, I've gotten to this solution, averaging about 150 (wall-...
forteddyt's user avatar
  • 314
14 votes
3 answers
11k views

I am inserting a list of dictionaries to a PostgreSQL database. The list will be growing quickly and the number of dict values (columns) is around 30. The simplified data: projects = [ {'name': '...
PythonSherpa's user avatar
  • 2,600
2 votes
4 answers
5k views

I am using my own pipeline to store the scrapped items into a PostgreSQL Database, I made an expansion a few days ago and I store the data into a 3 Databases now. So, I want to make the pipeline which ...
Morad Edwar's user avatar
  • 1,060
5 votes
1 answer
5k views

I have a very basic application that downloads data from a server via a socket connection one record at a time and writes each record to a postgresql database. This is only used by me. downloader = ...
darkpool's user avatar
  • 14.7k
3 votes
3 answers
2k views

I have a a number of XML files I need to open and then process to produce a large number of rows that are then inserted into several tables in a remote postgress database. To extract the XML data I ...
tanbog's user avatar
  • 610
5 votes
1 answer
4k views

I have a large table with ca. 10 million rows in PostgreSQL 9.4 database. It looks somewhat like this: gid | number1 | random | result | ... 1 | 2 | NULL | NULL | ... 2 | 15 | ...
n1000's user avatar
  • 5,354
6 votes
1 answer
3k views

I use Postgresql 9.4 for a model database. My table looks somewhat like this: CREATE TABLE table1 ( sid INTEGER PRIMARY KEY NOT NULL DEFAULT nextval('table1_sid_seq'::regclass), col1 INT, col2 INT, ...
n1000's user avatar
  • 5,354
2 votes
1 answer
3k views

I am having some problem with psycopg2 in python I have two disparate connections with corresponding cursors: 1. Source connection - source_cursor 2. Destination connection - dest_cursor Lets say ...
skybunk's user avatar
  • 863
0 votes
3 answers
133 views

Very new to python. I am trying to get the data from an RSS feed, parse the data and then insert the data to a database. My short bit of code gets the correct items and I can print the results but I ...
wiedhas's user avatar
  • 57