Python sqlalchemy.schema.DDLElement() Examples
The following are 5
code examples of sqlalchemy.schema.DDLElement().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.schema
, or try the search function
.
Example #1
Source File: impl.py From jbox with MIT License | 6 votes |
def _exec(self, construct, execution_options=None, multiparams=(), params=util.immutabledict()): if isinstance(construct, string_types): construct = text(construct) if self.as_sql: if multiparams or params: # TODO: coverage raise Exception("Execution arguments not allowed with as_sql") if self.literal_binds and not isinstance( construct, schema.DDLElement): compile_kw = dict(compile_kwargs={"literal_binds": True}) else: compile_kw = {} self.static_output(text_type( construct.compile(dialect=self.dialect, **compile_kw) ).replace("\t", " ").strip() + self.command_terminator) else: conn = self.connection if execution_options: conn = conn.execution_options(**execution_options) return conn.execute(construct, *multiparams, **params)
Example #2
Source File: ddl.py From sqlalchemy-redshift with MIT License | 6 votes |
def __init__(self, name, if_exists=False, cascade=False): """ Build the DropMaterializedView DDLElement. Parameters ---------- name: str name of the materialized view to drop if_exists: bool, optional if True, the IF EXISTS clause is added. This will make the query successful even if the view does not exist, i.e. it lets you drop a non-existant view. Defaults to False. cascade: bool, optional if True, the CASCADE clause is added. This will drop all views/objects in the DB that depend on this materialized view. Defaults to False. """ self.name = name self.if_exists = if_exists self.cascade = cascade
Example #3
Source File: impl.py From android_universal with MIT License | 6 votes |
def _exec(self, construct, execution_options=None, multiparams=(), params=util.immutabledict()): if isinstance(construct, string_types): construct = text(construct) if self.as_sql: if multiparams or params: # TODO: coverage raise Exception("Execution arguments not allowed with as_sql") if self.literal_binds and not isinstance( construct, schema.DDLElement): compile_kw = dict(compile_kwargs={"literal_binds": True}) else: compile_kw = {} self.static_output(text_type( construct.compile(dialect=self.dialect, **compile_kw) ).replace("\t", " ").strip() + self.command_terminator) else: conn = self.connection if execution_options: conn = conn.execution_options(**execution_options) return conn.execute(construct, *multiparams, **params)
Example #4
Source File: impl.py From alembic with MIT License | 5 votes |
def _exec( self, construct, execution_options=None, multiparams=(), params=util.immutabledict(), ): if isinstance(construct, string_types): construct = text(construct) if self.as_sql: if multiparams or params: # TODO: coverage raise Exception("Execution arguments not allowed with as_sql") if self.literal_binds and not isinstance( construct, schema.DDLElement ): compile_kw = dict(compile_kwargs={"literal_binds": True}) else: compile_kw = {} self.static_output( text_type( construct.compile(dialect=self.dialect, **compile_kw) ) .replace("\t", " ") .strip() + self.command_terminator ) else: conn = self.connection if execution_options: conn = conn.execution_options(**execution_options) return conn.execute(construct, *multiparams, **params)
Example #5
Source File: test_compiler.py From sqlalchemy with MIT License | 4 votes |
def test_dialect_specific(self): class AddThingy(DDLElement): __visit_name__ = "add_thingy" class DropThingy(DDLElement): __visit_name__ = "drop_thingy" @compiles(AddThingy, "sqlite") def visit_add_thingy_sqlite(thingy, compiler, **kw): return "ADD SPECIAL SL THINGY" @compiles(AddThingy) def visit_add_thingy(thingy, compiler, **kw): return "ADD THINGY" @compiles(DropThingy) def visit_drop_thingy(thingy, compiler, **kw): return "DROP THINGY" self.assert_compile(AddThingy(), "ADD THINGY") self.assert_compile(DropThingy(), "DROP THINGY") from sqlalchemy.dialects.sqlite import base self.assert_compile( AddThingy(), "ADD SPECIAL SL THINGY", dialect=base.dialect() ) self.assert_compile( DropThingy(), "DROP THINGY", dialect=base.dialect() ) @compiles(DropThingy, "sqlite") def visit_drop_thingy_sqlite(thingy, compiler, **kw): return "DROP SPECIAL SL THINGY" self.assert_compile( DropThingy(), "DROP SPECIAL SL THINGY", dialect=base.dialect() ) self.assert_compile(DropThingy(), "DROP THINGY")