[Tutor] _pg module and the insertion of random numbers...
kromag@nsacom.net
kromag@nsacom.net
Tue, 10 Apr 2001 22:42:59 -0700 (PDT)
I am attempting to insert random numbers into a PostGreSQL database using _pg
and random. I am unsure as to syntax when adding variables.
I have attempted the following:
import _pg
import random
db.connect('test', 'localhost')
db.query("insert into pork values(`random.randint(1,1000)`+ 'stuff' +'1-2-
1999')")
which returns a parse error at the second opening parenthesis.
I have also attempted:
db.query("insert into pork values('`random.randint(1,1000)`', 'stuff', '1-2-
1999')")
which inserts random.randint() as a literal string.
What am I doing wrong?