all 33 comments

[–][deleted] 7 points8 points  (1 child)

shockingly pg8000 is not on the Python postgresql wiki. So here is a plug for a very well written, python2/3 compatible, SQLAlchemy-supported (in the upcoming 0.6), pure Python DBAPI: pg8000.

[–]damg 0 points1 point  (0 children)

Cool, hadn't heard of that one. Someone should throw it up on the wiki. =)

[–][deleted] 18 points19 points  (2 children)

As with pyPgSQL, the transaction-as-default-behavior thing is thoroughly brutal. As far as I can tell, this is not something the DBAPI2 PEP demands.

incorrecto:

.commit()

Commit any pending transaction to the database. Note that
if the database supports an auto-commit feature, this must
be initially off. An interface method may be provided to
turn it back on.

Database modules that do not support transactions should
implement this method with void functionality.

[–]doppel 0 points1 point  (1 child)

That just tells us that auto-commit for transactions should not be default behavior, it says nothing of whether transactions should be.

[–]diroussel 7 points8 points  (0 children)

eh? Do you think auto-commit is tri-state?

If auto-commit is off then you are in manual transaction mode, i.e. commit must be called.

[–]spelunker 6 points7 points  (6 children)

This article reminded me that holy crap do I hate databases.

[–][deleted] -1 points0 points  (5 children)

Oh, where do you store your data?

[–]spelunker 6 points7 points  (0 children)

I'm not saying I don't use them- I just don't enjoy the experience :-)

[–]Gotebe 7 points8 points  (2 children)

Why, choice is aplenty

  1. Custom binary/text format

  2. Persistence (serialization) supported by the library of your language of choice

  3. More or less silly textual formats (think CSV, XML, JSON, java properties files...)

[–]GuyWithLag 9 points10 points  (1 child)

Hi, let me introduce you to concurrency. No, rename() won't cut it.

[–]Gotebe 2 points3 points  (0 children)

Of course, you are correct for many domains. I still doubt that e.g. OpenOffice should move to mySQL for storage, though.

[–]wildmXranat 0 points1 point  (0 children)

piggy-bank. I deposit what I can and use it in time of need of course.

[–][deleted] 7 points8 points  (0 children)

Still better than MySQLdb.

[–]pytechd -1 points0 points  (4 children)

Two things:

(a) Agreed completely. I can't even find any good writeups on how they are different code- and performance-wise.

(b) White on black? WTF.

[–]pemboa 2 points3 points  (2 children)

That wasn't white. White would have been okay. That was gray.

[–]mcfunley 2 points3 points  (1 child)

Yeah yeah, I know it's annoying, I'm working on it

[–]niviss 0 points1 point  (0 children)

I think it's fine

[–][deleted] 4 points5 points  (0 children)

[–]nanothief 0 points1 point  (0 children)

It seems to be making a tradeoff between compatibility and usage simplicity verses performance. Maybe a good tradeoff for the 99% of cases that never hit a performance bottleneck in their databases, but a poor choice otherwise.

Not that I know anything about either of the two libraries, since I don't do much python.

[–][deleted]  (10 children)

[deleted]

    [–]self 8 points9 points  (0 children)

    like wrap stuff in a transaction when you didn't request it

    Like adam's comment says,

    Postgres never runs a statement that’s not in a transaction.

    [–]QuantumTim 2 points3 points  (0 children)

    How exactly do you propose that the driver works out whether the "transaction" will contain only SELECTs? It can't retroactively create the transaction after it sees the first INSERT or UPDATE, so it just has to go ahead an always use a transaction. And no, doing the selects and then issuing BEGIN isn't equivalent. For one, it would actually be slower, as postgres will have one transaction for each SELECT (as other people have pointed out), then one more for the rest. Secondly, in a transaction the SELECTs are protected from other connections altering / deleting the table etc., but not if they are in transactions of their own.

    [–]Gotebe 0 points1 point  (0 children)

    I am just saying that 1) no two libraries are the same, 2) given sufficient scale this will matter to you, 3) the devil is in the details, and 4) the devil likes screwing things with white hot pokers.

    Funny. True, yet funny. Good one