1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | def no_style():
"""Returns a Django Style object that has no colors."""
class dummy(object):
def __getattr__(self, attr):
return lambda x: x
return dummy()
def clear_tables(*flush_tables):
from django.db import connection, transaction
cursor = connection.cursor()
statements = connection.ops.sql_flush(no_style(),
flush_tables,
connection.introspection.sequence_list())
for statement in statements:
cursor.execute(statement)
transaction.commit_unless_managed()
|
More like this
- oneliner to delete SQLite tables by kifkif 2 years, 3 months ago
- Load customized SQL by roppert 2 years, 11 months ago
- custom sql without table names by robharvey 4 years, 8 months ago
- Table Creation Using ORM Standalone by EliAndrewC 3 years, 11 months ago
- grep and delete sqlite tables by kifkif 2 years, 2 months ago
Comments