Quantcast
Channel: User Schwern - Stack Overflow
Viewing all articles
Browse latest Browse all 581

Answer by Schwern for Unable to insert or update data using Python into PostgreSQL

$
0
0

Each row you're inserting must be wrapped in parens.

insert into table(a,b,c) values (1,2,3);

See SQL tutorial: INSERT.


Two notes. First, don't concatenate SQL values as strings. This leaves you vulnerable to a visit from Little Bobby Tables aka a SQL Injection Attack. Use parameter substitution.

Second, you can insert multiple rows in a single insert. This makes bulk loading significantly faster.

insert into table(a,b,c) values  (1,2,3),  (4,5,6),  (7,8,9);

Viewing all articles
Browse latest Browse all 581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>