dbTalk Databases Forums  

psycopg help

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss psycopg help in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Scott Frankel
 
Posts: n/a

Default psycopg help - 10-13-2004 , 11:14 PM







First, apologies in advance for this somewhat OT post ...

I'm looking for a source of information on using the psycopg
interface to postgresql. A mailing list would be ideal. I've
poked at their wiki, but not found what I'm looking for.

Also, new to both postrgresql & psycopg, my questions appear
too basic for the doc/examples they provide with their installation.
i.e.:

- What's the appropriate syntax for specifying a primary key?

- What is the data type "text?" And how does it differ from
CHAR(len), &c.?

My very simple table creation test (based on their "first.py"
example is failing ... Here's what I'm trying. Non-pythonated
syntax works in pgsql:

no go:
curs.execute("""CREATE TABLE key_test (
key_col CHAR(9) PRIMARY KEY,
nother_col CHAR(256))""")

pure joy:
cs_test=# CREATE TABLE key_test (
cs_test(# key_col CHAR(9) PRIMARY KEY,
cs_test(# nother_col CHAR(256)
cs_test(# );

Thanks!
Scott


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Pierre-Frédéric Caillaud
 
Posts: n/a

Default Re: psycopg help - 10-14-2004 , 04:38 AM






Quote:
interface to postgresql. A mailing list would be ideal. I've
psycopg (AT) lists (DOT) initd.org


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #3  
Old   
Lee Harr
 
Posts: n/a

Default Re: psycopg help - 10-14-2004 , 03:52 PM



Quote:
My very simple table creation test (based on their "first.py"
example is failing ... Here's what I'm trying. Non-pythonated
syntax works in pgsql:

no go:
curs.execute("""CREATE TABLE key_test (
key_col CHAR(9) PRIMARY KEY,
nother_col CHAR(256))""")


Works fine for me:

Quote:
d=psycopg.connect('dbname=lee user=lee')
c=d.cursor()
c.execute("""CREATE TABLE key_test (
.... key_col CHAR(9) PRIMARY KEY,
.... nother_col CHAR(256))""")
Quote:
c.execute('''INSERT INTO key_test
.... VALUES ('test1', 'test2')''')
c.execute('''SELECT * FROM key_test''')
r=c.fetchall()
r
[('test1 ', 'test2
')]
Quote:
d.commit()

Perhaps if you showed us any error messages you
are getting we might be able to help.

Also helpful is the version of any and all pieces
(postgres version, and psycopg version, and
python version at least)

__________________________________________________ _______________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.com/


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.