Exemplo n.º 1
0
 def __init__(self, db):
     if isinstance(db, Database):
         self.db = db
     elif isinstance(db, dict):
         self.db = connect(**db)
     elif isinstance(db, str):
         self.db = connect(db)
     else:
         raise ValueError("db 参数类型错误")
Exemplo n.º 2
0
 def __init__(self, db):
     if isinstance(db, Database):
         self.db = db
     elif isinstance(db, engine.base.Engine) or hasattr(db, "cursor"):
         self.db = connect(driver=db)
     elif isinstance(db, dict):
         self.db = connect(**db)
     elif isinstance(db, str):
         self.db = connect(db)
     else:
         raise ValueError("db 参数类型错误")
Exemplo n.º 3
0
 def setUpClass(cls):
     # path = cls.get_file_path("src.db")
     # path = "sqlite:///" + path
     cls.db = connect("sqlite:///:memory:")
     create_src = """CREATE TABLE "src" ("uuid" INTEGER NOT NULL,"full_name" TEXT,PRIMARY KEY ("uuid"))"""
     cls.db.execute(create_src)
     create_dst = """CREATE TABLE "dst" ("id" INTEGER NOT NULL,"name" TEXT,PRIMARY KEY ("id"))"""
     cls.db.execute(create_dst)
     cls.db.get_table("src").insert(cls.src_record)
Exemplo n.º 4
0
 def setUpClass(cls):
     cls.db = connect(":memory:", driver="sqlite3")
Exemplo n.º 5
0
 def setUpClass(cls):
     cls.db = connect("sqlite:///:memory:")
Exemplo n.º 6
0
 def test_sqlalchemy_driver(self):
     with connect("sqlite:///:memory:") as db:
         db.execute("select 1")
     engine = create_engine("sqlite:///:memory:")
     with connect(driver=engine) as db:
         db.execute("select 1")
Exemplo n.º 7
0
 def test_common_driver(self):
     with connect(":memory:", driver="sqlite3") as db:
         db.execute("select 1")
     con = sqlite3.connect(":memory:")
     with connect(driver=con) as db:
         db.execute("select 1")
Exemplo n.º 8
0
 def get_db():
     return connect(":memory:", driver="sqlite3")
Exemplo n.º 9
0
 def get_db():
     return connect("sqlite:///:memory:")
Exemplo n.º 10
0
 def get_db():
     return connect("hive://localhost:10000/default")
Exemplo n.º 11
0
 def __init__(self, uri, table_name, condition=None):
     self.db = connect(uri)
     self.table_name = table_name
     self.condition = condition if condition else "1=1"