mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 00:46:33 +03:00
Use True/False instead of 1/0 to represent bool values
Slightly more modern, readable, and Pythonic.
This commit is contained in:
parent
afbbdd18b6
commit
3f890f8bbe
|
@ -73,8 +73,8 @@ class DictCursorBase(_cursor):
|
|||
raise NotImplementedError(
|
||||
"DictCursorBase can't be instantiated without a row factory.")
|
||||
super(DictCursorBase, self).__init__(*args, **kwargs)
|
||||
self._query_executed = 0
|
||||
self._prefetch = 0
|
||||
self._query_executed = False
|
||||
self._prefetch = False
|
||||
self.row_factory = row_factory
|
||||
|
||||
def fetchone(self):
|
||||
|
@ -135,23 +135,23 @@ class DictCursor(DictCursorBase):
|
|||
def __init__(self, *args, **kwargs):
|
||||
kwargs['row_factory'] = DictRow
|
||||
super(DictCursor, self).__init__(*args, **kwargs)
|
||||
self._prefetch = 1
|
||||
self._prefetch = True
|
||||
|
||||
def execute(self, query, vars=None):
|
||||
self.index = OrderedDict()
|
||||
self._query_executed = 1
|
||||
self._query_executed = True
|
||||
return super(DictCursor, self).execute(query, vars)
|
||||
|
||||
def callproc(self, procname, vars=None):
|
||||
self.index = OrderedDict()
|
||||
self._query_executed = 1
|
||||
self._query_executed = True
|
||||
return super(DictCursor, self).callproc(procname, vars)
|
||||
|
||||
def _build_index(self):
|
||||
if self._query_executed == 1 and self.description:
|
||||
if self._query_executed and self.description:
|
||||
for i in range(len(self.description)):
|
||||
self.index[self.description[i][0]] = i
|
||||
self._query_executed = 0
|
||||
self._query_executed = False
|
||||
|
||||
|
||||
class DictRow(list):
|
||||
|
@ -237,22 +237,21 @@ class RealDictCursor(DictCursorBase):
|
|||
def __init__(self, *args, **kwargs):
|
||||
kwargs['row_factory'] = RealDictRow
|
||||
super(RealDictCursor, self).__init__(*args, **kwargs)
|
||||
self._prefetch = 0
|
||||
|
||||
def execute(self, query, vars=None):
|
||||
self.column_mapping = []
|
||||
self._query_executed = 1
|
||||
self._query_executed = True
|
||||
return super(RealDictCursor, self).execute(query, vars)
|
||||
|
||||
def callproc(self, procname, vars=None):
|
||||
self.column_mapping = []
|
||||
self._query_executed = 1
|
||||
self._query_executed = True
|
||||
return super(RealDictCursor, self).callproc(procname, vars)
|
||||
|
||||
def _build_index(self):
|
||||
if self._query_executed == 1 and self.description:
|
||||
if self._query_executed and self.description:
|
||||
self.column_mapping = [d[0] for d in self.description]
|
||||
self._query_executed = 0
|
||||
self._query_executed = False
|
||||
|
||||
|
||||
class RealDictRow(dict):
|
||||
|
|
10
setup.py
10
setup.py
|
@ -528,7 +528,7 @@ parser.read('setup.cfg')
|
|||
# Choose a datetime module
|
||||
have_pydatetime = True
|
||||
have_mxdatetime = False
|
||||
use_pydatetime = int(parser.get('build_ext', 'use_pydatetime'))
|
||||
use_pydatetime = parser.getboolean('build_ext', 'use_pydatetime')
|
||||
|
||||
# check for mx package
|
||||
mxincludedir = ''
|
||||
|
@ -576,14 +576,14 @@ else:
|
|||
define_macros.append(('PSYCOPG_VERSION', PSYCOPG_VERSION_EX))
|
||||
|
||||
if parser.has_option('build_ext', 'have_ssl'):
|
||||
have_ssl = int(parser.get('build_ext', 'have_ssl'))
|
||||
have_ssl = parser.getboolean('build_ext', 'have_ssl')
|
||||
else:
|
||||
have_ssl = 0
|
||||
have_ssl = False
|
||||
|
||||
if parser.has_option('build_ext', 'static_libpq'):
|
||||
static_libpq = int(parser.get('build_ext', 'static_libpq'))
|
||||
static_libpq = parser.getboolean('build_ext', 'static_libpq')
|
||||
else:
|
||||
static_libpq = 0
|
||||
static_libpq = False
|
||||
|
||||
# And now... explicitly add the defines from the .cfg files.
|
||||
# Looks like setuptools or some other cog doesn't add them to the command line
|
||||
|
|
Loading…
Reference in New Issue
Block a user