Python sqlalchemy.dialects.sqlite.dialect() Examples
The following are 30
code examples of sqlalchemy.dialects.sqlite.dialect().
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.dialects.sqlite
, or try the search function
.
Example #1
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_anticipate_no_pk_non_composite_pk_prefetch(self): t = Table( "t", MetaData(), Column("x", Integer, primary_key=True, autoincrement=False), Column("q", Integer), ) d = postgresql.dialect() d.implicit_returning = False with expect_warnings( "Column 't.x' is marked as a member.*" "may not store NULL.$" ): self.assert_compile( t.insert(), "INSERT INTO t (q) VALUES (%(q)s)", params={"q": 5}, dialect=d, )
Example #2
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_prefix_with(self): table1 = self.tables.mytable stmt = ( table1.insert() .prefix_with("A", "B", dialect="mysql") .prefix_with("C", "D") ) self.assert_compile( stmt, "INSERT C D INTO mytable (myid, name, description) " "VALUES (:myid, :name, :description)", ) self.assert_compile( stmt, "INSERT A B C D INTO mytable (myid, name, description) " "VALUES (%s, %s, %s)", dialect=mysql.dialect(), )
Example #3
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_sql_expression_pk_autoinc_lastinserted(self): # test that postfetch isn't invoked for a SQL expression # in a primary key column. the DB either needs to support a lastrowid # that can return it, or RETURNING. [ticket:3133] metadata = MetaData() table = Table( "sometable", metadata, Column("id", Integer, primary_key=True), Column("data", String), ) stmt = table.insert().return_defaults().values(id=func.foobar()) compiled = stmt.compile(dialect=sqlite.dialect(), column_keys=["data"]) eq_(compiled.postfetch, []) eq_(compiled.returning, []) self.assert_compile( stmt, "INSERT INTO sometable (id, data) VALUES " "(foobar(), ?)", checkparams={"data": "foo"}, params={"data": "foo"}, dialect=sqlite.dialect(), )
Example #4
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_insert_from_select_seq(self): m = MetaData() t1 = Table( "t", m, Column("id", Integer, Sequence("id_seq"), primary_key=True), Column("data", String), ) stmt = t1.insert().from_select(("data",), select([t1.c.data])) self.assert_compile( stmt, "INSERT INTO t (data, id) SELECT t.data, " "nextval('id_seq') AS next_value_1 FROM t", dialect=postgresql.dialect(), )
Example #5
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_insert_from_select_cte_follows_insert_two(self): dialect = default.DefaultDialect() dialect.cte_follows_insert = True table1 = self.tables.mytable cte = table1.select().cte("c") stmt = cte.select() ins = table1.insert().from_select(table1.c, stmt) self.assert_compile( ins, "INSERT INTO mytable (myid, name, description) " "WITH c AS (SELECT mytable.myid AS myid, mytable.name AS name, " "mytable.description AS description FROM mytable) " "SELECT c.myid, c.name, c.description FROM c", dialect=dialect, )
Example #6
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_anticipate_no_pk_composite_pk_implicit_returning(self): t = Table( "t", MetaData(), Column("x", Integer, primary_key=True), Column("y", Integer, primary_key=True), ) d = postgresql.dialect() d.implicit_returning = True with expect_warnings( "Column 't.y' is marked as a member.*" "Note that as of SQLAlchemy 1.1," ): self.assert_compile( t.insert(), "INSERT INTO t (x) VALUES (%(x)s)", params={"x": 5}, dialect=d, )
Example #7
Source File: test_parseconnect.py From sqlalchemy with MIT License | 6 votes |
def test_wrapper_hooks(self): def get_dialect_cls(url): url.drivername = "sqlite" return url.get_dialect() global WrapperFactory WrapperFactory = Mock() WrapperFactory.get_dialect_cls.side_effect = get_dialect_cls registry.register("wrapperdialect", __name__, "WrapperFactory") from sqlalchemy.dialects import sqlite e = create_engine("wrapperdialect://") eq_(e.dialect.name, "sqlite") assert isinstance(e.dialect, sqlite.dialect) eq_( WrapperFactory.mock_calls, [ call.get_dialect_cls(url.make_url("sqlite://")), call.engine_created(e), ], )
Example #8
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_anticipate_no_pk_composite_pk_prefetch(self): t = Table( "t", MetaData(), Column("x", Integer, primary_key=True), Column("y", Integer, primary_key=True), ) d = postgresql.dialect() d.implicit_returning = False with expect_warnings( "Column 't.y' is marked as a member.*" "Note that as of SQLAlchemy 1.1," ): self.assert_compile( t.insert(), "INSERT INTO t (x) VALUES (%(x)s)", params={"x": 5}, dialect=d, )
Example #9
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_multi_multi(self): table1 = self.tables.mytable stmt = table1.insert().values([{"myid": 1, "name": "d1"}]) stmt = stmt.values( [{"myid": 2, "name": "d2"}, {"myid": 3, "name": "d3"}] ) self.assert_compile( stmt, "INSERT INTO mytable (myid, name) VALUES (%(myid_m0)s, " "%(name_m0)s), (%(myid_m1)s, %(name_m1)s), (%(myid_m2)s, " "%(name_m2)s)", checkparams={ "myid_m0": 1, "name_m0": "d1", "myid_m1": 2, "name_m1": "d2", "myid_m2": 3, "name_m2": "d3", }, dialect=postgresql.dialect(), )
Example #10
Source File: test_parseconnect.py From sqlalchemy with MIT License | 6 votes |
def test_custom(self): dbapi = MockDBAPI( foober=12, lala=18, hoho={"this": "dict"}, fooz="somevalue" ) def connect(): return dbapi.connect( foober=12, lala=18, fooz="somevalue", hoho={"this": "dict"} ) # start the postgresql dialect, but put our mock DBAPI as the # module instead of psycopg e = create_engine( "postgresql://", creator=connect, module=dbapi, _initialize=False ) e.connect()
Example #11
Source File: test_parseconnect.py From sqlalchemy with MIT License | 6 votes |
def test_import_base_dialects(self): # the globals() somehow makes it for the exec() + nose3. for name in ( "mysql", "firebird", "postgresql", "sqlite", "oracle", "mssql", ): exec( "from sqlalchemy.dialects import %s\ndialect = " "%s.dialect()" % (name, name), globals(), ) eq_(dialect.name, name)
Example #12
Source File: test_parseconnect.py From sqlalchemy with MIT License | 6 votes |
def test_query_string(self): u = url.make_url("dialect://user:pass@host/db?arg1=param1&arg2=param2") eq_(u.query, {"arg1": "param1", "arg2": "param2"}) eq_(str(u), "dialect://user:pass@host/db?arg1=param1&arg2=param2") u = url.make_url( "dialect://user:pass@host/db?arg1=param1&arg2=param2&arg2=param3" ) eq_(u.query, {"arg1": "param1", "arg2": ["param2", "param3"]}) eq_( str(u), "dialect://user:pass@host/db?arg1=param1&arg2=param2&arg2=param3", ) test_url = "dialect://user:pass@host/db?arg1%3D=param1&arg2=param+2" u = url.make_url(test_url) eq_(u.query, {"arg1=": "param1", "arg2": "param 2"}) eq_(str(u), test_url)
Example #13
Source File: test_insert.py From sqlalchemy with MIT License | 6 votes |
def test_positional(self): table1 = self.tables.mytable values = [ {"myid": 1, "name": "a", "description": "b"}, {"myid": 2, "name": "c", "description": "d"}, {"myid": 3, "name": "e", "description": "f"}, ] checkpositional = (1, "a", "b", 2, "c", "d", 3, "e", "f") dialect = default.DefaultDialect() dialect.supports_multivalues_insert = True dialect.paramstyle = "format" dialect.positional = True self.assert_compile( table1.insert().values(values), "INSERT INTO mytable (myid, name, description) VALUES " "(%s, %s, %s), (%s, %s, %s), (%s, %s, %s)", checkpositional=checkpositional, dialect=dialect, )
Example #14
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_single_bool_ten(self): self.assert_compile( or_(False), "0 = 1", dialect=default.DefaultDialect(supports_native_boolean=False), )
Example #15
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_not_is_distinct_from_postgresql(self): self.assert_compile( ~self.table1.c.myid.is_distinct_from(1), "mytable.myid IS NOT DISTINCT FROM %(myid_1)s", dialect=postgresql.dialect(), )
Example #16
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_is_distinct_from_postgresql(self): self.assert_compile( self.table1.c.myid.is_distinct_from(1), "mytable.myid IS DISTINCT FROM %(myid_1)s", dialect=postgresql.dialect(), )
Example #17
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_isnot_distinct_from_sqlite(self): self.assert_compile( self.table1.c.myid.isnot_distinct_from(1), "mytable.myid IS ?", dialect=sqlite.dialect(), )
Example #18
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_boolean_inversion_postgresql(self): self.assert_compile( ~self.table1.c.myid.match("somstr"), "NOT mytable.myid @@ to_tsquery(%(myid_1)s)", dialect=postgresql.dialect(), )
Example #19
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_six_pt_five(self): x = column("x") self.assert_compile( select([x]).where(or_(x == 7, true())), "SELECT x WHERE true" ) self.assert_compile( select([x]).where(or_(x == 7, true())), "SELECT x WHERE 1 = 1", dialect=default.DefaultDialect(supports_native_boolean=False), )
Example #20
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_five_b(self): c = column("x", Boolean) self.assert_compile( select([c], having=c), "SELECT x HAVING x = 1", dialect=self._dialect(False), )
Example #21
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_single_bool_nine(self): self.assert_compile( and_(True), "1 = 1", dialect=default.DefaultDialect(supports_native_boolean=False), )
Example #22
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_twelve(self): c = column("x", Boolean) # I don't have a solution for this one yet, # other than adding some heavy-handed conditionals # into compiler self.assert_compile( c.is_(true()), "x IS 1", dialect=self._dialect(False) )
Example #23
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_eleven(self): c = column("x", Boolean) self.assert_compile( c.is_(true()), "x IS true", dialect=self._dialect(True) )
Example #24
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_nine(self): self.assert_compile( and_(false(), true()), "0 = 1", dialect=self._dialect(False) )
Example #25
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_eight(self): self.assert_compile( and_(false(), true()), "false", dialect=self._dialect(True) )
Example #26
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_seven_d(self): t1 = table("t1", column("a")) t2 = table("t2", column("b")) self.assert_compile( join(t1, t2, onclause=false()), "t1 JOIN t2 ON false", dialect=self._dialect(True), )
Example #27
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_seven_c(self): t1 = table("t1", column("a")) t2 = table("t2", column("b")) self.assert_compile( join(t1, t2, onclause=true()), "t1 JOIN t2 ON true", dialect=self._dialect(True), )
Example #28
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_seven_b(self): t1 = table("t1", column("a")) t2 = table("t2", column("b")) self.assert_compile( join(t1, t2, onclause=false()), "t1 JOIN t2 ON 0 = 1", dialect=self._dialect(False), )
Example #29
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_six(self): self.assert_compile( or_(false(), true()), "1 = 1", dialect=self._dialect(False) )
Example #30
Source File: test_operators.py From sqlalchemy with MIT License | 5 votes |
def test_two_a(self): c = column("x", Boolean) self.assert_compile( select([c]).where(c), "SELECT x WHERE x = 1", dialect=self._dialect(False), )