Skip to content

Commit

Permalink
closes #317 by removing IF EXISTS and trailing semicolon
Browse files Browse the repository at this point in the history
  • Loading branch information
alimanfoo committed Apr 20, 2015
1 parent 6351e74 commit 62f35c5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TODO.rst
Expand Up @@ -54,4 +54,4 @@ DONE look truncate

DONE display truncate

TODO review all issues
DONE review all issues
6 changes: 3 additions & 3 deletions petl/io/db_create.py
Expand Up @@ -184,7 +184,7 @@ def make_create_table_statement(table, tablename, schema=None,
sql_dialect = None

return text_type(sqlalchemy.schema.CreateTable(sql_table)
.compile(dialect=sql_dialect)).strip() + ';'
.compile(dialect=sql_dialect)).strip()


def create_table(table, dbo, tablename, schema=None, commit=True,
Expand Down Expand Up @@ -228,7 +228,7 @@ def create_table(table, dbo, tablename, schema=None, commit=True,

def drop_table(dbo, tablename, schema=None, commit=True):
"""
Drop a database table if it exists.
Drop a database table.
Keyword arguments:
Expand All @@ -249,7 +249,7 @@ def drop_table(dbo, tablename, schema=None, commit=True):
if schema is not None:
tablename = _quote(schema) + '.' + tablename

sql = u'DROP TABLE IF EXISTS %s;' % tablename
sql = u'DROP TABLE %s' % tablename
_execute(sql, dbo, commit)


Expand Down
4 changes: 3 additions & 1 deletion petl/test/io/test_db_create.py
Expand Up @@ -69,7 +69,7 @@ def _test_create(dbo):
('a', 1),
('b', 2),
('c', 2))
todb(table, dbo, 'foo " bar`', create=True, drop=True)
todb(table, dbo, 'foo " bar`', create=True)
actual = fromdb(dbo, 'SELECT * FROM "foo "" bar`"')
ieq(table, actual)

Expand All @@ -80,6 +80,7 @@ def _setup_mysql(dbapi_connection):
# deal with quote compatibility
cursor.execute('SET SQL_MODE=ANSI_QUOTES')
cursor.execute('DROP TABLE IF EXISTS test_create')
cursor.execute('DROP TABLE IF EXISTS "foo "" bar`"')
cursor.close()
dbapi_connection.commit()

Expand All @@ -88,6 +89,7 @@ def _setup_generic(dbapi_connection):
# setup table
cursor = dbapi_connection.cursor()
cursor.execute('DROP TABLE IF EXISTS test_create')
cursor.execute('DROP TABLE IF EXISTS "foo "" bar`"')
cursor.close()
dbapi_connection.commit()

Expand Down

0 comments on commit 62f35c5

Please sign in to comment.