Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- import datetime
- import sys
- 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), '
- ' last_modified, quant FROM saldos WHERE estoque in (select id from estoque where id > 99)')
- cigarros = {}
- for rec in cur:
- curmatriz.execute(" SELECT "
- " (select nome from produto where grid = produto) nome, quantidade "
- " FROM "
- " lancto WHERE empresa = %d AND data >= '%s' "
- " and operacao in ('V', 'C', 'DF') and produto in"
- " (SELECT grid FROM produto WHERE codigo_barra = '%s') "
- % (rec[1], rec[2], rec[0]))
- info = curmatriz.fetchone()
- if info is not None:
- #info = info + (rec[3],)
- #cigarros[rec[0]] = info + rec
- saldo = rec[3] - info[1]
- print("[%s] %s = %d" % (rec[0], info[0], saldo))
- #print(cigarros[rec[0]])
- #for rec in
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement