mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
First fixed to the async core.
This commit is contained in:
parent
b19922ebf3
commit
61b4ff6e6f
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2004-11-20 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/cursor_type.c (_mogrify): ported %% fix from 1.1.15.
|
||||
|
||||
2004-11-20 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/cursor_type.c (psyco_curs_execute): added check to raise an
|
||||
exception if a cursor tries to .execute() while an async query is
|
||||
already in execution froma different cursor.
|
||||
|
||||
2004-11-20 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/connection_type.c (psyco_conn_cursor): renamed 'cursor'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* cursor_type.c - python interface to cursor objects
|
||||
*
|
||||
* Copyright (C) 2003 Federico Di Gregorio <fog@debian.org>
|
||||
* Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
|
||||
*
|
||||
* This file is part of psycopg.
|
||||
*
|
||||
|
@ -66,7 +66,7 @@ _mogrify(PyObject *var, PyObject *fmt, connectionObject *conn, PyObject **new)
|
|||
{
|
||||
PyObject *key, *value, *n, *item;
|
||||
char *d, *c;
|
||||
int index = 0;
|
||||
int index = 0, force = 0;
|
||||
|
||||
/* from now on we'll use n and replace its value in *new only at the end,
|
||||
just before returning. we also init *new to NULL to exit with an error
|
||||
|
@ -77,7 +77,7 @@ _mogrify(PyObject *var, PyObject *fmt, connectionObject *conn, PyObject **new)
|
|||
while(*c) {
|
||||
/* handle plain percent symbol in format string */
|
||||
if (c[0] == '%' && c[1] == '%') {
|
||||
c+=2;
|
||||
c+=2; force = 1;
|
||||
}
|
||||
|
||||
/* if we find '%(' then this is a dictionary, we:
|
||||
|
@ -224,8 +224,11 @@ _mogrify(PyObject *var, PyObject *fmt, connectionObject *conn, PyObject **new)
|
|||
}
|
||||
}
|
||||
|
||||
if (force && n == NULL)
|
||||
n = PyTuple_New(0);
|
||||
*new = n;
|
||||
return 0;
|
||||
|
||||
return 0;;
|
||||
}
|
||||
|
||||
#define psyco_curs_execute_doc \
|
||||
|
@ -246,6 +249,13 @@ psyco_curs_execute(cursorObject *self, PyObject *args, PyObject *kwargs)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (self->conn->async_cursor != NULL
|
||||
&& self->conn->async_cursor != (PyObject*)self) {
|
||||
PyErr_SetString(ProgrammingError,
|
||||
"asynchronous query already in execution");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (PyUnicode_Check(operation)) {
|
||||
PyObject *enc = PyDict_GetItemString(psycoEncodings,
|
||||
self->conn->encoding);
|
||||
|
@ -970,7 +980,7 @@ cursor_next(PyObject *self)
|
|||
{
|
||||
PyObject *res;
|
||||
|
||||
/* we don't parse argumente: psyco_curs_fetchone will do that for us */
|
||||
/* we don't parse arguments: psyco_curs_fetchone will do that for us */
|
||||
res = psyco_curs_fetchone((cursorObject*)self, NULL);
|
||||
|
||||
/* convert a None to NULL to signal the end of iteration */
|
||||
|
|
|
@ -1,12 +1,30 @@
|
|||
import datetime
|
||||
import time
|
||||
import psycopg
|
||||
|
||||
#d = datetime.timedelta(12, 100, 9876)
|
||||
#print d.days, d.seconds, d.microseconds
|
||||
#print psycopg.adapt(d).getquoted()
|
||||
|
||||
o = psycopg.connect("dbname=test")
|
||||
c = o.cursor()
|
||||
c.execute("SELECT 1.0 AS foo")
|
||||
print c.fetchmany(2)
|
||||
print c.fetchall()
|
||||
conn = psycopg.connect("dbname=test")
|
||||
curs = conn.cursor()
|
||||
#curs.execute("SELECT 1.0 AS foo")
|
||||
#print curs.fetchmany(2)
|
||||
#print curs.fetchall()
|
||||
|
||||
def sleep(curs):
|
||||
while not curs.isready():
|
||||
print "."
|
||||
time.sleep(.1)
|
||||
|
||||
#curs.execute("""
|
||||
# DECLARE zz INSENSITIVE SCROLL CURSOR WITH HOLD FOR
|
||||
# SELECT now();
|
||||
# FOR READ ONLY;""", async = 1)
|
||||
curs.execute("SELECT now() AS foo", async=1);
|
||||
sleep(curs)
|
||||
|
||||
#curs.execute("""
|
||||
# FETCH FORWARD 1 FROM zz;""", async = 1)
|
||||
curs.execute("SELECT now() AS bar", async=1);
|
||||
sleep(curs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user