fix connect arguments for sqlite3
This commit is contained in:
parent
aac61c2bb3
commit
992665f9ec
@ -234,6 +234,9 @@ class DBPools:
|
||||
conn = None
|
||||
cur = None
|
||||
if self.isAsyncDriver(dbname):
|
||||
if dbdesc['driver'] == 'sqlite3':
|
||||
conn = await driver.connect(dbdesc['kwargs']['dbname'])
|
||||
else:
|
||||
conn = await driver.connect(**dbdesc['kwargs'])
|
||||
cur = await conn.cursor()
|
||||
return True,conn,cur
|
||||
|
36
test/sqilit3_sql.py
Normal file
36
test/sqilit3_sql.py
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import asyncio
|
||||
from sqlor.dbpools import DBPools
|
||||
|
||||
async def exesqls(sqllines):
|
||||
sqls = txt.split(';')
|
||||
async with DBpools.sqlorContext('db') as sor:
|
||||
for sql in sqls:
|
||||
await sor.sqlExe(sql, {})
|
||||
|
||||
async def main():
|
||||
with codecs.open(sys.argv[2],'r', 'utf-8') as f:
|
||||
txt = f.read()
|
||||
await exesql(txt)
|
||||
|
||||
dbs = {
|
||||
"db":{
|
||||
"driver":"sqlite3",
|
||||
"kwargs":{
|
||||
"dbname":sys.argv[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 3:
|
||||
print(f'Usage:{sys.argv[0]} sqlite3_db_file sqlfile')
|
||||
sys.exit(1)
|
||||
|
||||
DBPools(dbs)
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user