Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- import xlsxwriter
- wb = xlsxwriter.Workbook("datapump.xlsx")
- ws = wb.add_worksheet()
- conn = psycopg2.connect("dbname=matrizpitstop user=postgres password=postgres host=srvmatriz")
- cur = conn.cursor()
- cur.execute("SELECT codigo, nome FROM produto LIMIT 500")
- ws.write(0, 0, "Codigo")
- ws.write(0, 1, "Nome")
- curow = 1
- for record in cur:
- for col in range(len(record)):
- ws.write(curow, col, record[col].decode('latin1'))
- curow+=1
- wb.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement