bugfix
This commit is contained in:
parent
f75c6f72f4
commit
9942fdcbf2
35
test/sqlite3_sql.py
Normal file
35
test/sqlite3_sql.py
Normal file
@ -0,0 +1,35 @@
|
||||
import sys
|
||||
import os
|
||||
import asyncio
|
||||
import codecs
|
||||
from sqlor.dbpools import DBPools
|
||||
|
||||
async def exesqls(sqllines):
|
||||
sqls = sqllines.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 exesqls(txt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 3:
|
||||
print(f'Usage:{sys.argv[0]} sqlite3_db_file sqlfile')
|
||||
sys.exit(1)
|
||||
dbs = {
|
||||
"db":{
|
||||
"driver":"sqlite3",
|
||||
"kwargs":{
|
||||
"dbname":sys.argv[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
DBPools(dbs)
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user