From: Dave S. <Dst...@em...> - 2002-06-12 21:43:54
|
Thanks for the tips! What I am looking for is even one step above that. When I load up Python, how do I tell is to import the PgSQL library so that it understands these commands? Thanks for your help... Dave Strickler CEO DWS - "The GroupWise Integration Experts" Boston * Austin * Belgium * Denmark http://www.emailsolutions.com (800) 999-5412 x10 ------------------------------------ Want to get rid of SPAM, Viruses, and unwanted content? MailWise Filter - "The E-Mail Firewall (tm) for Your Company" See http://www.emailsolutions.com/MailWise >>> Gerhard =?unknown-8bit?Q?H=E4ring?= <ger...@gm...> 06/12/02 05:17PM >>> * Dave Strickler < Dst...@em... > [2002-06-12 16:26 -0400]: > I'm new to Python and pyPgSQL, and learn best by example. Is there a set > of example code I could check out? The source distribution has an examples/ subdirectory with demo code. If you see a feature you want to use that is not covered by the demos, feel free to ask here, and I (or somebody else) can give example code for that. The set of features may be a little overwhelming. From all the features available, you'll mostly need only these patterns: # Open a connection to the database conn = PgSQL.connect(<connection parameters here>) # Obtain a 'cursor'. This is normally the only object that you'll use. cursor = conn.cursor() # Execute a simple SQL statement against the database cursor.execute("insert into test(name) values ('foo')") # Execute a SQL statement with appropriate parameter substitution and quoting # of these parameters done by PyPgSQL. cursor.execute("select from test where name=%s", ("foo",)) # Iterate over all results and do something with them (here. print the 'id' # column with all three ways of column access that pyPgSQL supports) for row in cursor.fetchall(): print row.id, row[0], row["id"] # Close the cursor. cursor.close() # Close the connection. conn.close() HTH, Gerhard -- mail: gerhard <at> bigfoot <dot> de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) _______________________________________________________________ Sponsored by: ThinkGeek at http://www.ThinkGeek.com/ _______________________________________________ Pypgsql-users mailing list Pyp...@li... https://lists.sourceforge.net/lists/listinfo/pypgsql-users |