This commit is contained in:
yumoqing 2025-10-23 12:15:41 +08:00
parent 1c694869bb
commit b4112adde7
6 changed files with 48 additions and 2 deletions

View File

@ -20,3 +20,8 @@ install_requires =
asyncio asyncio
jinja2 jinja2
[options.entry_points]
console_scripts =
dbpassword = sqlor.dbpassword:main
dbloader = sqlor.dbloader:main

7
sqlor/dbloader.py Normal file
View File

@ -0,0 +1,7 @@
from appPublic.worker import get_event_loop
async def main():
print('to be programming')
if __name__ == '__main__':
get_event_loop().run_until_complete(main())

17
sqlor/dbpassword.py Normal file
View File

@ -0,0 +1,17 @@
import os, sys
from appPublic.aes import aes_encode_b64
from appPublic.jsonConfig import getConfig
def main():
if len(sys.argv) < 3:
print(f'{sys.argv[0]} server_path dbuser_password')
sys.exit(1)
runpath = sys.argv[1]
password = sys.argv[2]
config = getConfig(runpath)
cyber = aes_encode_b64(config.password_key, sys.argv[2])
print(f'{password} encoded is {cyber}')
sys.exit(0)
if __name__ == '__main__':
main()

View File

@ -56,13 +56,24 @@ class SqlorPool:
self.sqlors.append(x) self.sqlors.append(x)
return x return x
async def test_sqlor(self, sor):
try:
await sor.execute(sor.test_sqlstr, {})
return True
except:
return False
@asynccontextmanager @asynccontextmanager
async def context(self): async def context(self):
async with self.sema: async with self.sema:
sqlors = [s for s in self.sqlors]
yielded_sqlor = None yielded_sqlor = None
for s in self.sqlors: for s in sqlors:
if not s.used: if not s.used:
if self.test_sqlor(s):
yielded_sqlor = s yielded_sqlor = s
else:
self.sqlors = [ x for x in self.sqlors if x != s ]
if not yielded_sqlor: if not yielded_sqlor:
yielded_sqlor = await self._new_sqlor() yielded_sqlor = await self._new_sqlor()
yielded_sqlor.used = True yielded_sqlor.used = True

View File

@ -66,6 +66,9 @@ from (
) )
where row_id >=$[from_line]$ and row_id < $[end_line]$""" where row_id >=$[from_line]$ and row_id < $[end_line]$"""
def test_sqlstr(self):
return "select 1 from dual"
def tablesSQL(self): def tablesSQL(self):
sqlcmd = """select sqlcmd = """select
lower(table_name) as name, lower(table_name) as name,

View File

@ -95,6 +95,9 @@ class SQLor(object):
key=getConfig().password_key key=getConfig().password_key
self.dbdesc.password = aes_decode_b64(key, self.dbdesc.password) self.dbdesc.password = aes_decode_b64(key, self.dbdesc.password)
def test_sqlstr(self):
return "select 1"
async def get_schema(self): async def get_schema(self):
def concat_idx_info(idxs): def concat_idx_info(idxs):
x = [] x = []