postgres example
QdlatY
qdlaty at ikom.pl
Sat Jan 12 16:28:54 EST 2002
More information about the Python-list mailing list
Sat Jan 12 16:28:54 EST 2002
- Previous message (by thread): postgres example
- Next message (by thread): postgres example
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Mark McEahern" <marklists at mceahern.com> wrote in news:mailman.1010866877.18040.python-list at python.org: > # create the db > $ createdb testdb > > # create a table > $ psql -c "create table foo (name varchar(100));" testdb > > # insert a record > $ psql -c "insert into foo values ('test');" testdb > > # start python > $ python > > # import PgSQL >>>> from pyPgSQL import PgSQL > > # get a connection >>>> conn = PgSQL.Connection("dbname=testdb") > > # get a cursor >>>> cursor = conn.cursor() > > # get record from foo >>>> sql = "select * from foo;" cursor.execute(sql) cursor.fetchone() > ['test'] Thanks for this example, but one thing, i used postgres much in my past, but i've never user "cursors" what is this ? -- QdlatY mailto: qdlaty at ikom.pl "Jezeli wydaje Ci sie ze wiesz wszystko - masz racje - wydaje Ci sie..."
- Previous message (by thread): postgres example
- Next message (by thread): postgres example
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list