Re: [DB-SIG] Context manager support for cursors

2018-07-25 Thread Federico Di Gregorio
On 06/21/2018 01:31 AM, Gerald Venzl wrote: Hi all, I was wondering whether there has been any particular reason that the specification of the Cursor object doesn’t implement a context manager to enable for example the “with” statement? Being able to use the “with” statement for database curso

Re: [DB-SIG] Prepared statements in python drivers

2014-04-09 Thread Federico Di Gregorio
d same name is prepared before, do nothing. > > Cursor.execute_prepared(name, params, stmt=None) > Execute prepared statement named name. > If stmt is not None, call Cursor.prepare(name, stmt, skip_on_dup=True) > before execute. This seems to complicate the code for no gain. The API previously propose

Re: [DB-SIG] Prepared statements in python drivers

2014-03-29 Thread Federico Di Gregorio
e you can call .execute() multiple times with the same (prepared) query string. federico -- Federico Di Gregorio federico.digrego...@dndg.it Di Nunzio & Di Gregorio srl http://dndg.it Do I know what a rhetorical question

Re: [DB-SIG] Make Python/SQL integration even smoother

2013-06-06 Thread Federico Di Gregorio
On 05/06/2013 21:07, M.-A. Lemburg wrote: > On 05.06.2013 20:55, big stone wrote: >> Hello M.-A., >> >> Afaik : >> "Linq" is not pure/transparent SQL > > Linq is SQL embedded into a programming language. C# and VB are > the only ones supporting this at the moment, AFAIK. LINQ is much much more th

Re: [DB-SIG] Make Python/SQL integration even smoother

2013-06-04 Thread Federico Di Gregorio
On 03/06/2013 20:05, big stone wrote: > Hello, > > I discovered recently the power of simplifying the integration between > python and its provided database sqlite3. > > In my dream, I would like to be able to querry in "sql syntax" all > objects of python environnement. You want LINQ [http://en

Re: [DB-SIG] Use of context managers with DB API 2

2012-11-06 Thread Federico Di Gregorio
ontext managers for transactions >> > (may not be the optimal solution, but it's already established) >> > * make cursors self-closing context managers (evident) >> > * not implement shortcut functions (see above) >> > >> > I

Re: [DB-SIG] conn.close() idempotence

2011-10-19 Thread Federico Di Gregorio
because there is no transaction in progress. I'd vote for idempotent .close() interpretation too. federico -- Federico Di Gregorio f...@initd.org Una nazionale senza neanche una nazione. -- macchinavap

Re: [DB-SIG] autocommit support in pep-249

2011-09-14 Thread Federico Di Gregorio
lt bug hunting session begins; 3. rollback => as (2), but data is lost. Having commit or rollbacks happen because of a bug really scares me: spurious data starts to popup into the database and finding the bugs usually isn't a piece of cake. That's why I vote for the exceptio

Re: [DB-SIG] Some obscurity with paramstyle

2011-07-21 Thread Federico Di Gregorio
the disavantage is that you can't easily work with composite types where you need to convert the primitive types and pack them into the composite (arrays, geographic data, ...) while adapt() is perfect for nested types. Anyway, happy that the discussion started :) federico -- Federico Di Greg

Re: [DB-SIG] Some obscurity with paramstyle

2011-07-19 Thread Federico Di Gregorio
Adaptation". If other implementors are interested I can write a short explanation about how it works and why it was chosen only for the Python->backend path and not for the reverse. federico -- Federico Di Gregorio federico.digrego...@dndg.it Studio Associato Di Nunzio

Re: [DB-SIG] Some obscurity with paramstyle

2011-07-19 Thread Federico Di Gregorio
if we don't yet support checkpoints in psycopg). federico -- Federico Di Gregorio federico.digrego...@dndg.it Studio Associato Di Nunzio e Di Gregorio http://dndg.it Quis custodiet ipsos custodes? -- Juvenal, Satires, VI, 347 ___

Re: [DB-SIG] Some obscurity with paramstyle

2011-07-18 Thread Federico Di Gregorio
27;%.2f'? > > My concrete problem was that I wanted to support Infinity and NaN where > Postgres has a different spelling from Python and needs quotes. This is > more difficult to implement if '%f' is allowed. IMO, nothing except %s is allowed. Letting the user choose a

Re: [DB-SIG] mogrify/query for adodbapi

2011-02-14 Thread Federico Di Gregorio
library sends query+parameters to the backend it is possible to build a "fake" query for logging/debugging purpuse. For example, we plan to move psycopg .executemany() to prepared queries and even in that case .mogrify() will return the full query, but in that case it will be not the

Re: [DB-SIG] Why so many Python drivers for PostgreSQL?

2010-01-18 Thread Federico Di Gregorio
nd build dicts instead of tuples (in fact this example is included in the psycopg2.extras module.) federico -- Federico Di Gregorio f...@initd.org Those who do not study Lisp are doomed to reimplement it. Poorly. -- from

Re: [DB-SIG] Having legs into diffents PostgreSQL versions?!?

2010-01-17 Thread Federico Di Gregorio
On 16/01/2010 16:50, wiztricks wrote: >> per definition the actual PostgreSQL driver shall be able to access >> > also ancient versions of PostgreSQL; and you should also be able to >> > profit from at least some of the bugfixes within the PostgreSQL >> > connection libraries of the last oneandahal

Re: [DB-SIG] Saving composed objects.

2008-07-10 Thread Federico Di Gregorio
On Thu, Jul 10, 2008 at 01:19:02PM +0100, Heston James - Cold Beans wrote: > I'm looking for your thoughts and advice on saving composed objects to the > database using the db API. Where do you place your persistence code? For > arguments sake let's look at a simple foo/bar example. Use one of the

Re: [DB-SIG] two phase commit API (again)

2008-02-27 Thread Federico Di Gregorio
Il giorno mer, 27/02/2008 alle 13.00 +0900, James Henstridge ha scritto: > I took the last round of feedback and integrated it into a new version > of the specification. If people are happy with this, what is the next > step? Fine for me. -- Federico Di Gregorio

Re: [DB-SIG] XID format (was: Two-phase commit API proposal)

2008-01-24 Thread Federico Di Gregorio
id and if it was built from parts to the single parts too. A transaction manager can discover if a recovered() transaction belongs to it by checking the 'format' (it can be None) and there is no need to drop xids from recover() calls. federico -- Federico Di Gregorio

Re: [DB-SIG] Two-phase commit API proposal (was Re: Any standard for two phase commit APIs?)

2008-01-22 Thread Federico Di Gregorio
d stay compatible with the API. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer[EMAIL PROTECTED] INIT.D Developer [EMAIL PROTECTED] Il panda ha l'apparato dige

Re: [DB-SIG] Two-phase commit API proposal (was Re: Any standard for two phase commit APIs?)

2008-01-22 Thread Federico Di Gregorio
on() ... begin_twophase() prepare_twophase() rollback_twophase() ... tpc_begin() tpc_prepare() tpc_rollback() federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer[EMAIL PROTECTED] INIT.D Developer

Re: [DB-SIG] Two-phase commit API proposal (was Re: Any standard for two phase commit APIs?)

2008-01-21 Thread Federico Di Gregorio
necessity for a one-phase commit in a two-phase transaction is rare. A simple API means early adoption by most of the adapters. > federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer

Re: [DB-SIG] Two-phase commit API proposal (was Re: Any standard for two phase commit APIs?)

2008-01-21 Thread Federico Di Gregorio
t;standard" transaction on some backends and not on others. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer[EMAIL PROTECTED] INIT.D Developer [EMAIL PROTE

Re: [DB-SIG] Two-phase commit API proposal (was Re: Any standard for two phase commit APIs?)

2008-01-21 Thread Federico Di Gregorio
about this one. Maybe we want an option added to xa_begin() to keep the prepared transaction open even if the connection drops. federico -- Federico Di Gregorio http://people.initd.org/fog DISCLAIMER. If I receive a message from you, you are agreeing that: 1. I am by defi

Re: [DB-SIG] how do I execute a query likte 'select * from mytable where id in (1, 2, 3)'?

2007-12-29 Thread Federico Di Gregorio
ect * from s2e where element = any (%(what)s)", > dict(what=[1,2,3])) > > using PostgreSQL arrays and the "any" function. psycopg2 supports direct conversion of tuples to IN clauses, doing quoting on the arguments. Just do: cs.execute("select * from s2e where eleme

Re: [DB-SIG] (slightly off topic) Very Large Database recommendations?

2007-10-04 Thread Federico Di Gregorio
handle it. If I remeber correctly I once got an email from a US hospital that was using PostgreSQL + psycopg to store medical data and full images into the database. They had millions of lines and were about to buy a 6TB SAN for the storage. You would be quite safe with 1,

Re: [DB-SIG] Controlling return types for DB APIs

2007-04-17 Thread Federico Di Gregorio
n->SQL part is perfect for adaptation and, for example, psycopg has a micro-protocols implementation to help with the adaptation of any Python object into a valid ISQLQuote one. Why two different systems? Because transating Python to SQL and SQL to Python are two very different operation

Re: [DB-SIG] Controlling return types for DB APIs

2007-04-17 Thread Federico Di Gregorio
Imho all that the DBAPI need is a way to specify type-casting functions (at global, connection and maybe column level) that allow the programmer to obtain exactly the Python type they need, given a backend type. federico -- Federico Di Gregorio http://people.initd.org/fog Deb

Re: [DB-SIG] Controlling return types for DB APIs

2007-04-17 Thread Federico Di Gregorio
all functions. Given the fact that the conversion happens inside a cursor and than the connection is available from the cursor object itself, something like: py_data = conversion_function(backend_data, cursor_object) Then we can at least make a standard for the registry methods. federico --

Re: [DB-SIG] Controlling return types for DB APIs

2007-04-17 Thread Federico Di Gregorio
uot;typecast_func"; and 2. you can use "nt" as a type object in comparaisons, just like other type object in the dbapi (STRING, NUMERIC, etc...) federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer

Re: [DB-SIG] comparing with lists via cx_Oracle

2007-01-08 Thread Federico Di Gregorio
use a tuple. It will get adapted into the right parenthesized form for SQL IN operator. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer[EMAIL PROTECTED] INIT.D Developer

Re: [DB-SIG] thoughts about OpenGIS extensions

2006-10-03 Thread Federico Di Gregorio
ate data from postgresql to the client program. I mean: how > you recognize it's gis data and not just any blob... Because they are real types in PostgreSQL (one of the few backends out there that allows for user-defined types) and not just blobs of data. federico -- Federico Di Gregor

Re: [DB-SIG] thoughts about OpenGIS extensions

2006-10-03 Thread Federico Di Gregorio
ou can register adapters (Python->PostgreSQL) and type-casters (PostgreSQL->Python) to convert your OpenGIS objects to PostgreSQL OpenGIS types and vice versa. This feature is used by the GeoTypes module that adds support for all geometrical types to psycopg. See: http://initd.org/tracker/psycop

Re: [DB-SIG] New take on PostgreSQL bindings for Python

2006-09-05 Thread Federico Di Gregorio
generated (and destroyed at the end of the current transaction) else, if name is None, a normal cursor is created. Then fetchXXX() methods do the right thing without the need to introduce extra methods. federico -- Federico Di Gregorio http://peopl

Re: [DB-SIG] DB-API unittests

2005-12-01 Thread Federico Di Gregorio
Il giorno gio, 01/12/2005 alle 13.32 +, Andy Chambers ha scritto: > --- Federico Di Gregorio <[EMAIL PROTECTED]> wrote: > > > Il giorno gio, 01/12/2005 alle 02.22 +, Andrew Chambers ha scritto: > > > - Evidently there is ambiguity about the way that dates shou

Re: [DB-SIG] DB-API unittests

2005-12-01 Thread Federico Di Gregorio
2005, 01, 01)) > Don't know about the others - I don't have them installed Ambiguity? IMHO, having to quote in the query string is obviously the wrong one. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer

Re: [DB-SIG] Accepted method for handling decimals?

2005-11-28 Thread Federico Di Gregorio
mer to override any of the default "type caster" functions with a user-defined one. Really usefull. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer[EMAIL PROTECTED] INIT.D Developer

Re: [DB-SIG] DB-API and 'COPY table FROM STDIN'

2005-11-12 Thread Federico Di Gregorio
xecute a 'COPY table FROM STDIN' command? If so, where would > stdin be in this case? I.e., where would one send the data? COPY is not part of the DBAPI. Some drivers, like psycopg, offer some kind of support for it but it is driver-dependent. federico -- Federico Di Gregorio

Re: [DB-SIG] pypg pure Python db driver for Postgresql

2005-07-13 Thread Federico Di Gregorio
Il giorno mer, 13/07/2005 alle 09.21 -0500, Randall Smith ha scritto: > I haven't done any speed optimization or even profiled the code, so that > looks really good to me. I think optimization might help with parameter > binding and type conversion. > > Did your tests include parameters? It is

Re: [DB-SIG] Abstraction layer confusion, ULA (was Re: Database Abstraction in Python)

2005-04-18 Thread Federico Di Gregorio
implement some subset of PEP 246 (Object adaptation). Maybe is this the way to go? Another this I really like to see in DBAPI 3 is asynchronous calls, cursors implementing the fileno() method (allowing them to be used in select calls), etc. -- Federico Di Gregorio http://people

Re: [DB-SIG] Table Oriented Programming

2005-01-29 Thread Federico Di Gregorio
Il giorno sab, 29-01-2005 alle 14:13 -0600, Ian Bicking ha scritto: > Federico Di Gregorio wrote: > > Il giorno ven, 28-01-2005 alle 15:11 -0600, Ian Bicking ha scritto: > > > >>It doesn't use bound parameters like ?, instead it does all the SQL > >>generat

Re: [DB-SIG] Table Oriented Programming

2005-01-29 Thread Federico Di Gregorio
Il giorno ven, 28-01-2005 alle 15:11 -0600, Ian Bicking ha scritto: > It doesn't use bound parameters like ?, instead it does all the SQL > generation itself including quotation. So it has to know what database > you are using to actually create the SQL, like "mysql", "postgresql", etc. This is