How to create tables in sqlite 3?

I just downloaded sqlite3.exe. It opens up as a command prompt. I created a table test & inserted a few entries in it. I used .backup test just in case. After I exit the program using .exit and reopened it I don't find the table listed under .tables nor can I run any query on it.

I need to quickly run an open source python program that makes use of this table & although I have worked with MySQL, I have no clue about sqlite. I need the minimal basics of sqlite. Can someone guide me through this or at least tell me how to permanently store my tables.

I have put this sqlite3.exe in Python folder assuming that python would then be able to read the sqlite files. Any ideas on this?

Answers


sqlite is built in to Python. You should be able to access your table like this:

import sqlite3
conn = sqlite3.connect('/path/to/my.db')
curs = conn.cursor()
curs.execute("SELECT a_column FROM my_table;").fetchone()
curs.close()
conn.close()

You can execute your DDL statements from Python as well. Make sure to commit the changes.

curs.execute("CREATE TABLE my_table (a_column text);")
conn.commit()

Need Your Help

JavaScript: Event Handlers: Where to declare variables - local or closure (vs overhead)?

javascript jquery javascript-events closures

I find myself writing various functions which contain event handlers. It feels preferable to declare the variables required by the handler functions at the root of the parent function (closure),

iAd frame returning wrong height on iPhone

ios iphone objective-c frame iad

I have an iAd which I am trying to position at the bottom of the screen though when I try to get the height of the ad so that I can put it at the bottom. This error only occurs when I enter the scr...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.