I have a few questions regarding the PyGreSql module. I'm new to python
so pardon my lack of knowledge. When trying to use any of the "get_"
functions (get_databases, get_tables) I receive an "AttributeError".
Same thing with "inserttable". Wondering if someone could post a quick
example including creation of a database connection and executing the
above three functions. I suspect my syntax is off because I can
successfully connect to and query from my database, but I can not find
any syntactical examples anywhere to confirm my suspicion.
Hi Taso,
here is a Python session you can try out (you can create an empty
database for testing with "createdb mydb"):
------
python
>>> from pg import DB
>>> db = DB('mydb')
>>> db.get_databases()
['template0', 'template1', 'mydb']
>>> db.query('create table mytable (n integer, t text)')
>>> db.get_tables()
['public.mytable']
>>> db.inserttable('mytable', [(1, 'hello'), (2, 'world')])
>>> db.query('select * from mytable').getresult()
[(1, 'hello'), (2, 'world')]
>>> db.get('mytable', 2, 'n')
{'n': 2, 't': 'world', 'oid(public.mytable)': ...}
------
Hope that helps.
-- Christoph
_______________________________________________
PyGreSQL mailing list
[email protected]
http://mailman.vex.net/mailman/listinfo/pygresql