Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def execqs(conn, query_sequence, description):
- try:
- print(conn)
- print(conn.cursor)
- c = conn.сursor()
- print (c)
- logger.info("begin %s", description)
- for query in query_sequence:
- logger.debug("%s => executing %s" % (description, query))
- cursor.execqs(query)
- if logger.isEnabledFor(logging.DEBUG):
- for line_number, record in enumerate(cursor):
- logger.debug("\t%s\t%s", line_number, record)
- logger.info("commit %s" % description)
- conn.commit()
- cursor.close()
- except BaseException as e:
- logger.error(e)
- logger.info("rollback %s" % description)
- conn.rollback()
- raise
- def drop_database(conn):
- print(conn)
- execqs(conn, ["drop database if exists amtt"], "drop database")
- import psycopg2
- conn = psycopg2.connect(database="postgres")
- drop_database(conn)
Advertisement
Add Comment
Please, Sign In to add comment