Re: Quick questions about globals and database connections

2017-04-06 Thread Jussi Piitulainen
DFS writes: > On 4/6/2017 10:54 AM, Python wrote: >> Le 06/04/2017 à 16:46, DFS a écrit : >>> On 4/5/2017 10:52 PM, Dan Sommers wrote: On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: > I have a simple hard-coded check in place before even trying to > connect: > > if dbtyp

Re: Quick questions about globals and database connections

2017-04-06 Thread Python
Le 06/04/2017 à 16:46, DFS a écrit : On 4/5/2017 10:52 PM, Dan Sommers wrote: On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: I have a simple hard-coded check in place before even trying to connect: if dbtype not in ('sqlite postgres'): print "db type must be sqlite or postgres" exit()

Re: Quick questions about globals and database connections

2017-04-06 Thread Jussi Piitulainen
DFS writes: > On 4/5/2017 10:52 PM, Dan Sommers wrote: >> On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: >> >>> I have a simple hard-coded check in place before even trying to connect: >>> >>> if dbtype not in ('sqlite postgres'): >>>print "db type must be sqlite or postgres" >>>exit() >>

Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote: > I have a simple hard-coded check in place before even trying to connect: > > if dbtype not in ('sqlite postgres'): >print "db type must be sqlite or postgres" >exit() That's not doing what you think it is. Hint: What is ('sqlite postgres

Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 14:56:12 -0400, DFS wrote: > I split the database connection code and settings into a module, so > the connection and setting values are available to other code modules > I have. Good work. > dbset.py > - > import sqlite3, psyco

Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 10:54:29 -0400, DFS wrote: > I have identical databases in sqlite and postgres. I want to run the > same code against them, but am having a small issue. > > Current code below throws the dreaded: > > NameError: global name 'db' is not defined > > on line 12 > > How do I f

Re: Quick questions about globals and database connections

2017-04-05 Thread John Gordon
In DFS writes: > I have identical databases in sqlite and postgres. I want to run the > same code against them, but am having a small issue. > Current code below throws the dreaded: > NameError: global name 'db' is not defined > on line 12 > How do I fix it? I want to keep dbconnect() as

Re: Quick questions about globals and database connections

2017-04-05 Thread Joel Goldstick
On Wed, Apr 5, 2017 at 11:09 AM, Python wrote: > Le 05/04/2017 à 16:54, DFS a écrit : >> >> I have identical databases in sqlite and postgres. I want to run the >> same code against them, but am having a small issue. >> >> Current code below throws the dreaded: >> >> NameError: global name 'db' i

Re: Quick questions about globals and database connections

2017-04-05 Thread Python
Le 05/04/2017 à 16:54, DFS a écrit : I have identical databases in sqlite and postgres. I want to run the same code against them, but am having a small issue. Current code below throws the dreaded: NameError: global name 'db' is not defined on line 12 How do I fix it? I want to keep dbconne