-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 14.05.2011 09:49, Remy Blank wrote:
> Steffen Hoffmann wrote:
>> Reading through the different db connectors I've got the
>> impression, that only SQLite is returning an (empty) object in the
>> no-results case. I wrote some debug statements into the code as
>> follows:
>>
>>> r = cursor.execute(sql, src) self.env.log.debug('CURSOR = ' +
>>> str(r)) self.env.log.debug('ROWSATTR = ' + str(getattr(r, 'rows',
>>> None))) if not r is None: row = r.fetchone()
>>> self.env.log.debug('ROW = ' + str(row)) if not row is None:
>>> return row
>
> You should call fetchone() on the cursor, not on the result of
> cursor.execute():
FYI, this is the final result. Thank you again for taking your time to
help me understand.
#5667: [Patch] Added compatibility with PostgreSQL
-
-------------------------------------+--------------------------------------
Reporter: [email protected] | Owner: hasienda
Type: defect | Status: assigned
Priority: normal | Component: TracFormsPlugin
Severity: normal | Resolution:
Keywords: PostgreSQL compatibility | Release: 0.11
-
-------------------------------------+--------------------------------------
Comment (by hasienda):
(In [10211]): TracFormsPlugin: Anwser a long standing question from inside
formdb.py, refs #5667.
# Please, please tell me there's a better way to do this...
Yes, it is: Don't try to re-invent the Trac db cursor but just go and use
the
native one, and i.e. MySQL/PostgreSQL compatibility comes for free by
itself.
SQL rewrite details
* introduce native Trac db type selector
* drop DBCursor class with a lot of proprietary, unused special
methods
* remove 'DROP' SQL statements before dropping entire tables anyway
* separate index creation SQL statements obsoleted and common suffix
for Trac db indexes to new !TracForms indexes created automagicly
using db_connector.to_sql()
Thanks to osimons, who made this finally clear to me and again
encouraged me to do things in a cleaner fashion. Thanks to rblank for
valuable hints on proper use of Trac db cursors. And many thanks to
Nelso G. Jost for patiently testing published code as well as many more
private iterations of code changes in Trac environments using the
PostgreSQL db connector.
- -- Ticket URL: <http://trac-hacks.org/ticket/5667#comment:24> Trac Hacks
- - Plugins Macros etc. <http://trac-hacks.org> Trac Hacks - Hosting for
Trac Plugins, Macros, etc.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk3UHSEACgkQ31DJeiZFuHc1lgCg2ZRBJIR+mtO4ZsRYHknINLZ4
/uIAoOlfaWpA8xEksQouFdUzO/OGgYqy
=zlCW
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en.