1) I am trying to list table names in a database using python,
2) also need help specifically calling a table and getting whats in it.
if you dont know python thats fine, i just need help in the syntax of sqlite queries
Here is my code for getting table names,
i don't understand the format it results. what does " u' "in front of the names mean. why is there a comma after the names? yes i am new to databases...
dbconn = sqlite3.connect(unicode('data.db'))
cursor = dbconn.cursor()
cursor.execute( "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;")
data = cursor.fetchall()
print data
it gives the following.
~$ python sqltest.py [(u'table1',), (u'table2',)]
i was expecting something like table1 table2
How do i list the stuff in specific table? lets say table2
this did not work for some reason.
c.execute('select * from table2')
data2 = cursor.fetchall()
print data2
I really appreciate all your help
This post has been edited by nacholibre: 29 November 2010 - 02:09 PM

New Topic/Question
Reply



MultiQuote



|