mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Fixed connection parameters.
This commit is contained in:
parent
7d2109f979
commit
0c56bc95df
|
@ -1,5 +1,8 @@
|
|||
2005-06-13 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/psycopgmodule.c (psyco_connect): changed the port keyword
|
||||
parameter type to int (instead of string); this should fix #23.
|
||||
|
||||
* psycopg/cursor_type.c (_psyco_curs_execute): now checks for empty queries
|
||||
and raise a ProgrammingError if appropriate (closes: #24).
|
||||
|
||||
|
|
4
NEWS
4
NEWS
|
@ -4,6 +4,10 @@ What's new in psycopg 2.0 beta 4
|
|||
* No more segfaults when a UNICODE query can't be converted to the
|
||||
backend encoding.
|
||||
|
||||
* No more segfaults on empty queries.
|
||||
|
||||
* psycopg2.connect() now takes an integer for the port keyword parameter.
|
||||
|
||||
What's new in psycopg 2.0 beta 3
|
||||
--------------------------------
|
||||
|
||||
|
|
|
@ -98,26 +98,30 @@ psyco_connect(PyObject *self, PyObject *args, PyObject *keywds)
|
|||
{
|
||||
PyObject *conn, *factory = NULL;
|
||||
|
||||
int idsn=-1;
|
||||
int idsn=-1, iport=-1;
|
||||
char *dsn=NULL, *database=NULL, *user=NULL, *password=NULL;
|
||||
char *host=NULL, *port=NULL, *sslmode=NULL;
|
||||
char *host=NULL, *sslmode=NULL;
|
||||
char port[16];
|
||||
|
||||
static char *kwlist[] = {"dsn", "database", "host", "port",
|
||||
"user", "password", "sslmode",
|
||||
"connection_factory", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sssssssO", kwlist,
|
||||
&dsn, &database, &host, &port,
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sssisssO", kwlist,
|
||||
&dsn, &database, &host, &iport,
|
||||
&user, &password, &sslmode, &factory)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (iport > 0)
|
||||
snprintf(port, 16, "%d", iport);
|
||||
|
||||
if (dsn == NULL) {
|
||||
int l = 36; /* len("dbname= user= password= host= port=\0") */
|
||||
|
||||
if (database) l += strlen(database);
|
||||
if (host) l += strlen(host);
|
||||
if (port) l += strlen(port);
|
||||
if (iport > 0) l += strlen(port);
|
||||
if (user) l += strlen(user);
|
||||
if (password) l += strlen(password);
|
||||
if (sslmode) l += strlen(sslmode);
|
||||
|
@ -133,7 +137,7 @@ psyco_connect(PyObject *self, PyObject *args, PyObject *keywds)
|
|||
idsn = _psyco_connect_fill_dsn(dsn, " dbname=", database, idsn);
|
||||
if (host)
|
||||
idsn = _psyco_connect_fill_dsn(dsn, " host=", host, idsn);
|
||||
if (port)
|
||||
if (iport > 0)
|
||||
idsn = _psyco_connect_fill_dsn(dsn, " port=", port, idsn);
|
||||
if (user)
|
||||
idsn = _psyco_connect_fill_dsn(dsn, " user=", user, idsn);
|
||||
|
|
Loading…
Reference in New Issue
Block a user