mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-08-04 12:20:09 +03:00
retab to 8 whitespace characters, remove superflous whitespace
This commit is contained in:
parent
7a1d1791d3
commit
3e1908c55d
|
@ -26,7 +26,7 @@ import pool
|
||||||
import psycopg2
|
import psycopg2
|
||||||
from psycopg2.extensions import INTEGER, LONGINTEGER, FLOAT, BOOLEAN, DATE, TIME
|
from psycopg2.extensions import INTEGER, LONGINTEGER, FLOAT, BOOLEAN, DATE, TIME
|
||||||
from psycopg2.extensions import TransactionRollbackError, register_type
|
from psycopg2.extensions import TransactionRollbackError, register_type
|
||||||
from psycopg2 import NUMBER, STRING, ROWID, DATETIME
|
from psycopg2 import NUMBER, STRING, ROWID, DATETIME
|
||||||
|
|
||||||
|
|
||||||
# the DB object, managing all the real query work
|
# the DB object, managing all the real query work
|
||||||
|
@ -107,17 +107,17 @@ class DB(TM, dbi_db.DB):
|
||||||
def make_mappings(self):
|
def make_mappings(self):
|
||||||
"""Generate the mappings used later by self.convert_description()."""
|
"""Generate the mappings used later by self.convert_description()."""
|
||||||
self.type_mappings = {}
|
self.type_mappings = {}
|
||||||
for t, s in [(INTEGER,'i'), (LONGINTEGER, 'i'), (NUMBER, 'n'),
|
for t, s in [(INTEGER,'i'), (LONGINTEGER, 'i'), (NUMBER, 'n'),
|
||||||
(BOOLEAN,'n'), (ROWID, 'i'),
|
(BOOLEAN,'n'), (ROWID, 'i'),
|
||||||
(DATETIME, 'd'), (DATE, 'd'), (TIME, 'd')]:
|
(DATETIME, 'd'), (DATE, 'd'), (TIME, 'd')]:
|
||||||
for v in t.values:
|
for v in t.values:
|
||||||
self.type_mappings[v] = (t, s)
|
self.type_mappings[v] = (t, s)
|
||||||
|
|
||||||
def convert_description(self, desc, use_psycopg_types=False):
|
def convert_description(self, desc, use_psycopg_types=False):
|
||||||
"""Convert DBAPI-2.0 description field to Zope format."""
|
"""Convert DBAPI-2.0 description field to Zope format."""
|
||||||
items = []
|
items = []
|
||||||
for name, typ, width, ds, p, scale, null_ok in desc:
|
for name, typ, width, ds, p, scale, null_ok in desc:
|
||||||
m = self.type_mappings.get(typ, (STRING, 's'))
|
m = self.type_mappings.get(typ, (STRING, 's'))
|
||||||
items.append({
|
items.append({
|
||||||
'name': name,
|
'name': name,
|
||||||
'type': use_psycopg_types and m[0] or m[1],
|
'type': use_psycopg_types and m[0] or m[1],
|
||||||
|
@ -158,7 +158,7 @@ class DB(TM, dbi_db.DB):
|
||||||
return ()
|
return ()
|
||||||
self.putconn()
|
self.putconn()
|
||||||
return self.convert_description(c.description, True)
|
return self.convert_description(c.description, True)
|
||||||
|
|
||||||
## query execution ##
|
## query execution ##
|
||||||
|
|
||||||
def query(self, query_string, max_rows=None, query_data=None):
|
def query(self, query_string, max_rows=None, query_data=None):
|
||||||
|
@ -205,5 +205,5 @@ class DB(TM, dbi_db.DB):
|
||||||
except StandardError, err:
|
except StandardError, err:
|
||||||
self._abort()
|
self._abort()
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
return self.convert_description(desc), res
|
return self.convert_description(desc), res
|
||||||
|
|
Loading…
Reference in New Issue
Block a user