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
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
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
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
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
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
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
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
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
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
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
___
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
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
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
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
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
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
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
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
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
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
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
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
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
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,
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
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
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
--
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
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
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
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
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
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
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
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
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
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
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
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
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
41 matches
Mail list logo