mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Added function to drop a test table in the doctest.
This commit is contained in:
parent
a54336f7b4
commit
f134bceb00
14
doc/conf.py
14
doc/conf.py
|
@ -241,13 +241,17 @@ def test_connect():
|
||||||
conn = test_connect()
|
conn = test_connect()
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
||||||
def create_test_table():
|
def drop_test_table(name):
|
||||||
|
cur.execute("SAVEPOINT drop_test_table;")
|
||||||
try:
|
try:
|
||||||
cur.execute("CREATE TABLE test (id SERIAL PRIMARY KEY, num INT, data TEXT)")
|
cur.execute("DROP TABLE %s;" % name)
|
||||||
except:
|
except:
|
||||||
conn.rollback()
|
cur.execute("ROLLBACK TO SAVEPOINT drop_test_table;")
|
||||||
cur.execute("DELETE FROM test")
|
conn.commit()
|
||||||
cur.execute("SELECT setval('test_id_seq', 1, False)")
|
|
||||||
|
def create_test_table():
|
||||||
|
drop_test_table('test')
|
||||||
|
cur.execute("CREATE TABLE test (id SERIAL PRIMARY KEY, num INT, data TEXT)")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user