Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd3337c6

Browse files
committed
> I am backing out this patch. Please resubmit with this corrected. Thanks.
>> I am running Python 1.5.Therein lies the problem... :)Since it appears you have the requirement of supporting old pythonversions, attached is just the pgdb.py part of the patch (with a fix forDateTime handling). It has the same functionality but certainly won't bequite as fast. Given the absence of _PyString_Join in python1.5, it's apain to get the C variants working for all versions. The pgdb.py patchdoes leaves the hooks in, should someone wish to do the optimization at alater point.Elliot Lee
1 parenta7ade2b commitd3337c6

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

‎src/interfaces/python/pgdb.py

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -260,32 +260,40 @@ def setoutputsize(self, size, col = 0):
260260
pass
261261

262262

263-
def_quote(x):
264-
iftype(x)==types.StringType:
265-
x="'"+string.replace(
266-
string.replace(str(x),'\\','\\\\'),"'","''")+"'"
267-
268-
eliftype(x)in (types.IntType,types.LongType,types.FloatType):
269-
pass
270-
elifxisNone:
271-
x='NULL'
272-
elifhasattr(x,'__pg_repr__'):
273-
x=x.__pg_repr__()
274-
else:
275-
raiseInterfaceError,'do not know how to handle type %s'%type(x)
276-
277-
returnx
278-
279-
def_quoteparams(s,params):
280-
ifhasattr(params,'has_key'):
281-
x= {}
282-
fork,vinparams.items():
283-
x[k]=_quote(v)
284-
params=x
285-
else:
286-
params=tuple(map(_quote,params))
287-
288-
returns%params
263+
try:
264+
_quote=_pg.quote_fast
265+
_quoteparams=_pg.quoteparams_fast
266+
except (NameError,AttributeError):
267+
def_quote(x):
268+
iftype(x)==DateTime.DateTimeType:
269+
x=str(x)
270+
iftype(x)==types.StringType:
271+
x="'"+string.replace(
272+
string.replace(str(x),'\\','\\\\'),"'","''")+"'"
273+
274+
eliftype(x)in (types.IntType,types.LongType,types.FloatType):
275+
pass
276+
elifxisNone:
277+
x='NULL'
278+
eliftype(x)in (types.ListType,types.TupleType):
279+
x='(%s)'%string.join(map(lambdax:str(_quote(x)),x),',')
280+
elifhasattr(x,'__pg_repr__'):
281+
x=x.__pg_repr__()
282+
else:
283+
raiseInterfaceError,'do not know how to handle type %s'%type(x)
284+
285+
returnx
286+
287+
def_quoteparams(s,params):
288+
ifhasattr(params,'has_key'):
289+
x= {}
290+
fork,vinparams.items():
291+
x[k]=_quote(v)
292+
params=x
293+
else:
294+
params=tuple(map(_quote,params))
295+
296+
returns%params
289297

290298
### connection object
291299

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp