Thanks Andy and Vernon!
The sql variable was left in the code unintentionally when I was rewriting
the code in order to post it here.
nevertheless, it was very enlightening to read your replies as I seldom have
the opportunity to read other people python-db code.
The little experience I have with
On Sun, Nov 21, 2010 at 8:42 PM, Andy Dustman wrote:
>
>
> You never actually set sql anywhere, so you'll always get a NameError
> instead of IOError. It would probably be better to not catch the
> exception at all in this function.
> --
> Question the answers
> __
Andy Dustman wrote:
On Sun, Nov 21, 2010 at 3:02 PM, John Q. Public wrote:
Is this how my createdb() method should look like?
How would you write this method so it is both readable and correct?
Thank you for your time and patience.
def createdb(self):
try:
con = sqlite3.connect(db
On Sun, Nov 21, 2010 at 3:02 PM, John Q. Public wrote:
>
> Is this how my createdb() method should look like?
> How would you write this method so it is both readable and correct?
> Thank you for your time and patience.
>
> def createdb(self):
> try:
> con = sqlite3.connect(db)
>
I find this code to be very readable.
I, personally, would not use quite so much vertical white space, like whole
lines with only a "(", but that is a matter of aesthetics only. My senses
were probably permanently marred by learning to program using punched cards
and 14 7/8 inch printer paper. Ver
Is this how my createdb() method should look like?
How would you write this method so it is both readable and correct?
Thank you for your time and patience.
def createdb(self):
try:
con = sqlite3.connect(db)
cur = con.cursor()
cur.execute('''
CREAT
python + sqlite3 wrote:
>
> Vernon, 10x for the detailed reply.
>
> I understand from your answer that each SQL statement should have it's own
> cursor so in my case,
> since the db contains 5 tables, creating it will require 5 cursors.
You can reuse cursors to run multiple commands. However, if
Vernon, 10x for the detailed reply.
I understand from your answer that each SQL statement should have it's own
cursor so in my case,
since the db contains 5 tables, creating it will require 5 cursors.
The parametrized queries will become handy when I'll write the INSERT and
SELECT part of the co
This answer is based on the generic db-api, not specifically on sqlite3.
1. transactions are controlled by the connection object, not the cursor
object.
so:
import sqlite3 as db
conn = db.connect('someDatabase')
while someCondition:
c1 = conn.cursor()
c2 = conn.cursor()
c1.execute('update s
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 natu
10 matches
Mail list logo