[DB-SIG] Python db programming conventions

python + sqlite3 sqlite3.user at gmail.com
Sat Oct 16 09:08:14 CEST 2010


Hello all,

As I'm new to both python and sqlite3, I would like to consult regarding
python db programming conventions. After I finished to design my application
and started coding it, I found myself dealing with the following questions:

1. Since the db contains more than one table, it seems natural to use
transaction in order to create the it. The transaction contains more than
one SQL statement and therefor can't be executed using cursor.execute(). I
found the method cursor.executescript() that documented as non-standard, is
that the method to be used? is there better way of creating the db?

2. In order to create and maintain the db tables, I'll need to use several
long transactions (CREATE, EDIT, INSERT, DELETE etc.). Where should I place
the SQL code for them? Should my class contain the SQL queries as private
string properties? should I define the SQL queries as class member
functions? Or is it better to store the SQL code in separate SQL files and
execute the files somehow (is it possible to execute SQL file using
sqlite3)?

I'd appreciate your help,
Cheers
-- 
View this message in context: http://old.nabble.com/Python-db-programming-conventions-tp29977345p29977345.html
Sent from the Python - db-sig mailing list archive at Nabble.com.



More information about the DB-SIG mailing list