I have one application in web2py



This application executes somes instructions for me in my sql bank



One this make download of one table choosed in one directory



I put one file called produtos.csv in directory called requisicao

And then the application make download of table called produtos inside
my bank and create a copy in format .CSV for directory called consulta



See the code for this:



def make_backup():

    requisicoes= os.listdir(RequisicaoPath )

    requisicoes = filter(filtro.search, requisicoes)

    for requisicao in requisicoes :

        try:

            table=requisicao .split('.')[0]

            path = os.path.join(ConsultPath ,"%s.csv"
%table).replace('\\','/')

            id_field = SPECIALS.get(table,'id')

            q = getattr(db[table],id_field ) > 0

            open(path , 'w').write(str(db(q).select()))



 
os.remove(os.path.join(RequisicaoPath ,requisicao ).replace('\\','/'))

        except: pass





But I need execute one search inside one table for a critery
specified.



Then I am trying create the code. But fault some details



See:



def pesquisa_in_db():

    pesquisa= os.listdir(PesquisaPath )

    pesquisa = filter(filtro.search, pesquisa)

    for da_pesquisa in pesquisa :

        try:

            table=da_pesquisa .split('.')[0]

            path = os.path.join(PesquisaPath ,"%s.csv"
%table).replace('\\','/')

            id_field = SPECIALS.get(table,'id')

            q = getattr(db[table],id_field ) > 0



‘the command up make



            open(path , 'w').write(str(db(q).select()))



 
os.remove(os.path.join(RequisicaoPath ,requisicao ).replace('\\','/'))

        except: pass





 the above command takes the whole table and placed in the variable q
and the next:
            open (path, 'w'.) write (str (db (q). select ()))
opens a path and records all variable (which is the copy of the table)
in the file mentioned in the back

But what I need is:
in this command:
             q = getattr (db [table] id_field)> 0
Instead of writing all the table that he ran a search (research) in
the table following a criterion.
Consider the example:

strSQL = "SELECT count (*) FROM products WHEREqtdFretegratis the
frete_gratis and idprod = 1 in (SELECTFROM orders WHERE idprod
idcompra = '" & intOrderID & "')"

And then just record the contents of strSQL ok?

            open (path, 'w'.) write (str (strsql.select ()))

Please
Correct me if I'm wrong.
Thank you.
Mario



Data-House Informática

Passeio São Luiz, 209-Sala A

Zona Norte

15385-000   /   Ilha Solteira-p

E-mail: [email protected]

MSN: [email protected]

SKYPE: mario.antonio.pereira

Site: www.isashop.com.br






Reply via email to