[web2py] Re: Query DB from a python script

2011-06-07 Thread Massimo Di Pierro
Try this

from gluon import DAL
db=DAL('sqlite://fw.db',folder='applications/app/
databases',auto_import=True)

rows = db(db.fw).select()
dest_ip_string ='%s' % rows[1].dst_ip

On Jun 7, 5:22 pm, chewbacca rru...@gmail.com wrote:
 Hello all.

 I am using web2py to generate a form and save the information in a DB.
 User puts the information on the form and the information gets saved
 in the DB sqlite.
 I want to be able query the DB and get the information the from the
 user input.

 =
 file DB.PY looks like this:
 ...
 db=DAL(sqlite://db.db)

 db.define_table('fw',
     Field('dst_ip'),
 ...
 =
 I am trying to connect to the DB like this:

 from gluon.sql import *
 db=DAL('sqlite://fw.db')

 but it does not appear to be working
 =

 How do I write a python script to be able to print the information
 from the user input from the form stored in the DB?

 it works when I query the DB direclty from inside the Web2py 
 Controllers  Shell 

 rows = db(db.fw).select()
 dest_ip_string ='%s' % rows[1]['dst_ip']

 Thank You


[web2py] Re: Query DB from a python script

2011-06-07 Thread Massimo Di Pierro
make sure you have the most recent web2py

On Jun 7, 5:22 pm, chewbacca rru...@gmail.com wrote:
 Hello all.

 I am using web2py to generate a form and save the information in a DB.
 User puts the information on the form and the information gets saved
 in the DB sqlite.
 I want to be able query the DB and get the information the from the
 user input.

 =
 file DB.PY looks like this:
 ...
 db=DAL(sqlite://db.db)

 db.define_table('fw',
     Field('dst_ip'),
 ...
 =
 I am trying to connect to the DB like this:

 from gluon.sql import *
 db=DAL('sqlite://fw.db')

 but it does not appear to be working
 =

 How do I write a python script to be able to print the information
 from the user input from the form stored in the DB?

 it works when I query the DB direclty from inside the Web2py 
 Controllers  Shell 

 rows = db(db.fw).select()
 dest_ip_string ='%s' % rows[1]['dst_ip']

 Thank You