bugfix
This commit is contained in:
parent
8a550b98bd
commit
9ecc577202
@ -178,6 +178,12 @@ class DBPools:
|
|||||||
self.databases = databases
|
self.databases = databases
|
||||||
self.meta = {}
|
self.meta = {}
|
||||||
|
|
||||||
|
def get_dbname(self, name):
|
||||||
|
desc = self.database.get(name)
|
||||||
|
if not desc:
|
||||||
|
return None
|
||||||
|
return desc.get('dbname')
|
||||||
|
|
||||||
def addDatabase(self,name,desc):
|
def addDatabase(self,name,desc):
|
||||||
self.databases[name] = desc
|
self.databases[name] = desc
|
||||||
|
|
||||||
|
11
sqlor/sor.py
11
sqlor/sor.py
@ -68,6 +68,9 @@ class SQLor(object):
|
|||||||
self.sqlvp = sqlvp
|
self.sqlvp = sqlvp
|
||||||
self.sqlvs = sqlvs
|
self.sqlvs = sqlvs
|
||||||
self.dbdesc = dbdesc
|
self.dbdesc = dbdesc
|
||||||
|
self.dbname = self.dbdesc.get('dbname')
|
||||||
|
if self.dbname:
|
||||||
|
self.dbname = self.dbname.lower()
|
||||||
self.writer = None
|
self.writer = None
|
||||||
self.convfuncs = {}
|
self.convfuncs = {}
|
||||||
self.cc = ConditionConvert()
|
self.cc = ConditionConvert()
|
||||||
@ -564,12 +567,12 @@ class SQLor(object):
|
|||||||
fields = [ i['name'] for i in desc['fields']]
|
fields = [ i['name'] for i in desc['fields']]
|
||||||
fns = ','.join(fields)
|
fns = ','.join(fields)
|
||||||
vfns = ','.join(['${%s}$' % n for n in fields ])
|
vfns = ','.join(['${%s}$' % n for n in fields ])
|
||||||
sql = 'insert into %s (%s) values (%s)' % (tablename,fns,vfns)
|
sql = 'insert into %s (%s.%s) values (%s)' % (self.dbname, tablename,fns,vfns)
|
||||||
await self.runSQL({'sql_string':sql},ns,None)
|
await self.runSQL({'sql_string':sql},ns,None)
|
||||||
|
|
||||||
async def R(self,tablename,ns,filters=None):
|
async def R(self,tablename,ns,filters=None):
|
||||||
desc = await self.I(tablename)
|
desc = await self.I(tablename)
|
||||||
sql = 'select * from %s' % tablename.lower()
|
sql = 'select * from %s.%s' % (self.dbname, tablename.lower())
|
||||||
if filters:
|
if filters:
|
||||||
dbf = DBFilter(filters)
|
dbf = DBFilter(filters)
|
||||||
sub = dbf.genFilterString(ns)
|
sub = dbf.genFilterString(ns)
|
||||||
@ -606,7 +609,7 @@ class SQLor(object):
|
|||||||
u = [ '%s = ${%s}$' % (i,i) for i in newData ]
|
u = [ '%s = ${%s}$' % (i,i) for i in newData ]
|
||||||
c_str = ','.join(c)
|
c_str = ','.join(c)
|
||||||
u_str = ','.join(u)
|
u_str = ','.join(u)
|
||||||
sql = 'update %s set %s where %s' % (tablename,
|
sql = 'update %s.%s set %s where %s' % (self.dbname, tablename,
|
||||||
u_str,c_str)
|
u_str,c_str)
|
||||||
await self.runSQL({'sql_string':sql},ns,None)
|
await self.runSQL({'sql_string':sql},ns,None)
|
||||||
pass
|
pass
|
||||||
@ -617,7 +620,7 @@ class SQLor(object):
|
|||||||
condi = [ i for i in desc['summary'][0]['primary']]
|
condi = [ i for i in desc['summary'][0]['primary']]
|
||||||
c = [ '%s = ${%s}$' % (i,i) for i in condi ]
|
c = [ '%s = ${%s}$' % (i,i) for i in condi ]
|
||||||
c_str = ','.join(c)
|
c_str = ','.join(c)
|
||||||
sql = 'delete from %s where %s' % (tablename,c_str)
|
sql = 'delete from %s.%s where %s' % (self.dbname, tablename,c_str)
|
||||||
await self.runSQL({'sql_string':sql},ns,None)
|
await self.runSQL({'sql_string':sql},ns,None)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user