Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- import os
- conn = psycopg2.connect('dbname=cigarro host=10.40.140.25 user=postgres password=postgres')
- cur = conn.cursor()
- connmatriz = psycopg2.connect('dbname=matrizpitstop host=10.40.140.25 user=postgres password=postgres')
- curmatriz = connmatriz.cursor()
- cur.execute("SELECT produto, (select empresa from estoque where id = estoque), "
- " quant, last_turn FROM saldos WHERE estoque > 99")
- for rec in cur:
- qry = "SELECT sum(quantidade), sum(valor), (select nome from produto where grid = produto) FROM lancto " \
- " WHERE empresa = %d and produto = " \
- " (select grid from produto where codigo_barra = '%s') " \
- " and hora >= '%s' " \
- " and operacao in ('C', 'V', 'DF') " \
- " GROUP BY produto" %\
- (rec[1], rec[0], rec[3])
- #print(qry)
- curmatriz.execute(qry)
- info = curmatriz.fetchone()
- if info is not None:
- print("%s\n\tVenda = %d Saldo = %d" % (info[2], info[0], rec[2]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement