This commit is contained in:
yumoqing 2021-01-03 04:36:27 +00:00
parent 8cfed2cb9d
commit 63a4e89a7e
6 changed files with 34 additions and 9 deletions

20
docs/postgresql.md Normal file
View File

@ -0,0 +1,20 @@
# POSTGRESQL
## create database
create database testdb;
## create user
create role guest with login;
## grat privileges
grant all privileges on database testdb to guest;
### grant table privileges
psql -d testdb
grant all privileges on all tables in schema public to guest;

View File

@ -5,4 +5,6 @@ class AioPostgresqlor(PostgreSQLor):
def isMe(self,name):
return name=='aiopg'
async def commit(self):
pass

View File

@ -256,7 +256,10 @@ class DBPools:
await p.release(conn)
"""
if self.isAsyncDriver(dbname):
await cur.close()
try:
await cur.close()
except:
pass
else:
try:
cur.fetchall()

View File

@ -4,7 +4,7 @@ VARCHAR({{len}})
{%- elif type=='char' -%}
CHAR({{len}})
{%- elif type=='long' or type=='int' or type=='short' -%}
INTEGER
NUMERIC(30,0)
{%- elif type=='float' or type=='double' or type=='ddouble' -%}
NUMERIC({{len}},{{dec}})
{%- elif type=='date' -%}

View File

@ -38,7 +38,7 @@ class PostgreSQLor(SQLor):
}
@classmethod
def isMe(self,name):
return name=='psycopg2' or name=='aiopg' or name=='pyguass'
return name=='psycopg2' or name=='pyguass'
def grammar(self):
return {
@ -48,13 +48,13 @@ class PostgreSQLor(SQLor):
def placeHolder(self,varname,i):
if varname=='__mainsql__' :
return ''
return '$%d' % i
return '%%(%s)s' % varname
def dataConvert(self,dataList):
x = super().dataConvert(dataList)
if x == []:
return None
return x
if type(dataList) == type({}):
return dataList
d = { i['name']:i['value'] for i in dataList }
return d
def pagingSQLmodel(self):
return u"""select *

View File

@ -201,7 +201,7 @@ class SQLor(object):
using a opened cursor to run a SQL statment with variable, the variable is setup in NS namespace
return a cursor with data
"""
markedSQL,datas = self.maskingSQL(sql,NS)
markedSQL, datas = self.maskingSQL(sql,NS)
datas = self.dataConvert(datas)
try:
if self.async_mode: