From 9942fdcbf21dffe82cc1bb49f8f33ca7e6c65bcc Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 16 Nov 2022 11:01:29 +0800 Subject: [PATCH] bugfix --- test/sqlite3_sql.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/sqlite3_sql.py diff --git a/test/sqlite3_sql.py b/test/sqlite3_sql.py new file mode 100644 index 0000000..59e6694 --- /dev/null +++ b/test/sqlite3_sql.py @@ -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()) + +