Created
April 12, 2014 18:17
-
-
Save Stiivi/10549265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateTableAsSelect(Executable, ClauseElement): | |
def __init__(self, table, select): | |
self.table = table | |
self.select = select | |
@compiles(CreateTableAsSelect) | |
def visit_create_table_as_select(element, compiler, **kw): | |
preparer = compiler.dialect.preparer(compiler.dialect) | |
full_name = preparer.format_table(element.table) | |
return "CREATE TABLE %s AS (%s)" % ( | |
element.table, | |
compiler.process(element.select) | |
) | |
@compiles(CreateTableAsSelect, "sqlite") | |
def visit_create_table_as_select(element, compiler, **kw): | |
preparer = compiler.dialect.preparer(compiler.dialect) | |
full_name = preparer.format_table(element.table) | |
return "CREATE TABLE %s AS %s" % ( | |
element.table, | |
compiler.process(element.select) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment