D
D
des1roer2015-06-18 07:07:32
Python
des1roer, 2015-06-18 07:07:32

Python can't configure dump?

Вот такой код:

con = psycopg2.connect(user='*', password='*', host='*', dbname='*', port=5432)
cur = con.cursor()

today = date.today()
month = today.replace(year=today.year - 1, month=today.month, day=today.day)
month = month.strftime("%Y-%m")
cur.execute('''select * from "SC_Tag"."tagdata_%s";'''% month)

ver = cur.fetchone()
print ver

try:
    dumpcmd ='''PGPASSWORD="*" pg_dump -h *.ru -p 5432 -U * -F p -E UTF8 -Z 9 -t "SC_Tag"."tagdata_2014-12" -v -f "D:\postgres\pg\my12.gzip" DB_ASUTP_2'''    
    cur.execute('''DROP TABLE "SC_Tag"."tagdata_%s";'''% month)
    print 'lol'
except:
    print "I can't drop our test database!"
print cur.query

There are two questions:
1. deleting a table on the server does not work
cur.execute('''DROP TABLE "SC_Tag"."tagdata_%s";'''% month)

there are rights. the select passes, the error in try does not go away, it
print cur.query
produces normal sql
DROP TABLE "SC_Tag"."tagdata_2014-06";

2. dumpcmd doesn't work
dumpcmd ='''pg_dump -h *ru -p 5432 -U user -F p -E UTF8 -Z 9 -t "SC_Tag"."tagdata_2014-12" -v -f "D:\postgres\pg\my12.gzip" DB_ASUTP_2'''

connection string taken from EMS Pg Manager

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oscar Django, 2015-06-18
@des1roer

Do you commit?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question