diff --git a/docs/postgresql.md b/docs/postgresql.md new file mode 100644 index 0000000..39d3b26 --- /dev/null +++ b/docs/postgresql.md @@ -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; + + diff --git a/sqlor/aiopostgresqlor.py b/sqlor/aiopostgresqlor.py index 7094ebc..1a9f8f4 100755 --- a/sqlor/aiopostgresqlor.py +++ b/sqlor/aiopostgresqlor.py @@ -5,4 +5,6 @@ class AioPostgresqlor(PostgreSQLor): def isMe(self,name): return name=='aiopg' + async def commit(self): + pass diff --git a/sqlor/dbpools.py b/sqlor/dbpools.py index de9c9ae..397817f 100755 --- a/sqlor/dbpools.py +++ b/sqlor/dbpools.py @@ -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() diff --git a/sqlor/ddl_template_postgresql.py b/sqlor/ddl_template_postgresql.py index 4d73127..a6c13b4 100755 --- a/sqlor/ddl_template_postgresql.py +++ b/sqlor/ddl_template_postgresql.py @@ -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' -%} diff --git a/sqlor/postgresqlor.py b/sqlor/postgresqlor.py index 15895c1..243b1c2 100755 --- a/sqlor/postgresqlor.py +++ b/sqlor/postgresqlor.py @@ -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 * diff --git a/sqlor/sor.py b/sqlor/sor.py index 49108e3..a622f90 100755 --- a/sqlor/sor.py +++ b/sqlor/sor.py @@ -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: