mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-14 08:56:00 +00:00
- Windows warning fixes
- Fixed key lookup (InstallDir) in setup.py
This commit is contained in:
@ -30,14 +30,13 @@ def get_config():
|
|||||||
connector_key = OpenKey(local_reg,
|
connector_key = OpenKey(local_reg,
|
||||||
'SOFTWARE\\MariaDB Corporation\\MariaDB Connector C 64-bit',
|
'SOFTWARE\\MariaDB Corporation\\MariaDB Connector C 64-bit',
|
||||||
access=KEY_READ | KEY_WOW64_64KEY)
|
access=KEY_READ | KEY_WOW64_64KEY)
|
||||||
|
|
||||||
cc_version = QueryValueEx(connector_key, "Version")
|
cc_version = QueryValueEx(connector_key, "Version")
|
||||||
if cc_version[0] < required_version:
|
if cc_version[0] < required_version:
|
||||||
print(
|
print(
|
||||||
"MariaDB Connector/Python requires MariaDB Connector/C >= %s (found version: %s") \
|
"MariaDB Connector/Python requires MariaDB Connector/C >= %s (found version: %s") \
|
||||||
% (required_version, cc_version[0])
|
% (required_version, cc_version[0])
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
cc_instdir = QueryValueEx(Key, "InstallDir")
|
cc_instdir = QueryValueEx(connector_key, "InstallDir")
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print("Could not find InstallationDir of MariaDB Connector/C. "
|
print("Could not find InstallationDir of MariaDB Connector/C. "
|
||||||
|
2
setup.py
2
setup.py
@ -19,7 +19,7 @@ setup(name='mariadb',
|
|||||||
description='Python MariaDB extension',
|
description='Python MariaDB extension',
|
||||||
author='Georg Richter',
|
author='Georg Richter',
|
||||||
license='LGPL 2.1',
|
license='LGPL 2.1',
|
||||||
url='http://www.mariadb.com',
|
url='https://www.github.com/MariaDB/mariadb-connector-python',
|
||||||
ext_modules=[Extension('mariadb', ['src/mariadb.c', 'src/mariadb_connection.c', 'src/mariadb_exception.c', 'src/mariadb_cursor.c', 'src/mariadb_codecs.c', 'src/mariadb_field.c', 'src/mariadb_dbapitype.c', 'src/mariadb_indicator.c'],
|
ext_modules=[Extension('mariadb', ['src/mariadb.c', 'src/mariadb_connection.c', 'src/mariadb_exception.c', 'src/mariadb_cursor.c', 'src/mariadb_codecs.c', 'src/mariadb_field.c', 'src/mariadb_dbapitype.c', 'src/mariadb_indicator.c'],
|
||||||
include_dirs=cfg.includes,
|
include_dirs=cfg.includes,
|
||||||
library_dirs= cfg.lib_dirs,
|
library_dirs= cfg.lib_dirs,
|
||||||
|
@ -169,7 +169,7 @@ void field_fetch_fromtext(MrdbCursor *self, char *data, unsigned int column)
|
|||||||
unsigned long utf8len;
|
unsigned long utf8len;
|
||||||
|
|
||||||
self->values[column]= PyUnicode_FromStringAndSize((const char *)data, (Py_ssize_t)length[column]);
|
self->values[column]= PyUnicode_FromStringAndSize((const char *)data, (Py_ssize_t)length[column]);
|
||||||
utf8len= PyUnicode_GET_LENGTH(self->values[column]);
|
utf8len= (unsigned long)PyUnicode_GET_LENGTH(self->values[column]);
|
||||||
if (utf8len > self->fields[column].max_length)
|
if (utf8len > self->fields[column].max_length)
|
||||||
self->fields[column].max_length= utf8len;
|
self->fields[column].max_length= utf8len;
|
||||||
break;
|
break;
|
||||||
@ -237,7 +237,7 @@ void field_fetch_callback(void *data, unsigned int column, unsigned char **row)
|
|||||||
long long l= sint8korr(*row);
|
long long l= sint8korr(*row);
|
||||||
self->values[column]= (self->fields[column].flags & UNSIGNED_FLAG) ?
|
self->values[column]= (self->fields[column].flags & UNSIGNED_FLAG) ?
|
||||||
PyLong_FromUnsignedLongLong((unsigned long long)l) :
|
PyLong_FromUnsignedLongLong((unsigned long long)l) :
|
||||||
PyLong_FromLong(l);
|
PyLong_FromLongLong(l);
|
||||||
*row+= 8;
|
*row+= 8;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ void field_fetch_callback(void *data, unsigned int column, unsigned char **row)
|
|||||||
length= mysql_net_field_length(row);
|
length= mysql_net_field_length(row);
|
||||||
|
|
||||||
self->values[column]= PyUnicode_FromStringAndSize((const char *)*row, (Py_ssize_t)length);
|
self->values[column]= PyUnicode_FromStringAndSize((const char *)*row, (Py_ssize_t)length);
|
||||||
utf8len= PyUnicode_GET_LENGTH(self->values[column]);
|
utf8len= (unsigned long)PyUnicode_GET_LENGTH(self->values[column]);
|
||||||
if (utf8len > self->fields[column].max_length)
|
if (utf8len > self->fields[column].max_length)
|
||||||
self->fields[column].max_length= utf8len;
|
self->fields[column].max_length= utf8len;
|
||||||
*row+= length;
|
*row+= length;
|
||||||
@ -509,7 +509,7 @@ static uint8_t mariadb_get_parameter(MrdbCursor *self,
|
|||||||
"MariaDB %s doesn't support indicator variables. Required version is 10.2.6 or newer", mysql_get_server_info(self->stmt->mysql));
|
"MariaDB %s doesn't support indicator variables. Required version is 10.2.6 or newer", mysql_get_server_info(self->stmt->mysql));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
param->indicator= MrdbIndicator_AsLong(column);
|
param->indicator= (char)MrdbIndicator_AsLong(column);
|
||||||
param->value= NULL; /* you can't have both indicator and value */
|
param->value= NULL; /* you can't have both indicator and value */
|
||||||
} else if (column == Py_None)
|
} else if (column == Py_None)
|
||||||
{
|
{
|
||||||
@ -559,7 +559,7 @@ static uint8_t mariadb_get_parameter_info(MrdbCursor *self,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
param->buffer_type= pinfo.type;
|
param->buffer_type= pinfo.type;
|
||||||
bits= pinfo.bits;
|
bits= (uint32_t)pinfo.bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i < self->array_size; i++)
|
for (i=0; i < self->array_size; i++)
|
||||||
@ -580,7 +580,7 @@ static uint8_t mariadb_get_parameter_info(MrdbCursor *self,
|
|||||||
if (pinfo.type == MYSQL_TYPE_LONGLONG)
|
if (pinfo.type == MYSQL_TYPE_LONGLONG)
|
||||||
{
|
{
|
||||||
if (pinfo.bits > bits)
|
if (pinfo.bits > bits)
|
||||||
bits= pinfo.bits;
|
bits= (uint32_t)pinfo.bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -631,7 +631,7 @@ uint8_t mariadb_check_bulk_parameters(MrdbCursor *self,
|
|||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
if (!(self->array_size= PyList_Size(data)))
|
if (!(self->array_size= (uint32_t)PyList_Size(data)))
|
||||||
{
|
{
|
||||||
mariadb_throw_exception(self->stmt, Mariadb_InterfaceError, 1,
|
mariadb_throw_exception(self->stmt, Mariadb_InterfaceError, 1,
|
||||||
"Empty parameter list. At least one row must be specified");
|
"Empty parameter list. At least one row must be specified");
|
||||||
@ -649,7 +649,7 @@ uint8_t mariadb_check_bulk_parameters(MrdbCursor *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!self->param_count && !self->is_prepared)
|
if (!self->param_count && !self->is_prepared)
|
||||||
self->param_count= PyTuple_Size(obj);
|
self->param_count= (uint32_t)PyTuple_Size(obj);
|
||||||
if (!self->param_count ||
|
if (!self->param_count ||
|
||||||
self->param_count != PyTuple_Size(obj))
|
self->param_count != PyTuple_Size(obj))
|
||||||
{
|
{
|
||||||
@ -695,7 +695,7 @@ uint8_t mariadb_check_execute_parameters(MrdbCursor *self,
|
|||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
if (!self->is_prepared)
|
if (!self->is_prepared)
|
||||||
self->param_count= PyTuple_Size(data);
|
self->param_count= (uint32_t)PyTuple_Size(data);
|
||||||
|
|
||||||
if (!self->param_count)
|
if (!self->param_count)
|
||||||
{
|
{
|
||||||
|
@ -946,7 +946,7 @@ static int MrdbConnection_setdb(MrdbConnection *self, PyObject *db,
|
|||||||
PyErr_SetString(PyExc_TypeError, "Argument must be string");
|
PyErr_SetString(PyExc_TypeError, "Argument must be string");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
schema= PyUnicode_AsUTF8(db);
|
schema= (char *)PyUnicode_AsUTF8(db);
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
rc= mysql_select_db(self->mysql, schema);
|
rc= mysql_select_db(self->mysql, schema);
|
||||||
@ -1048,9 +1048,9 @@ static PyObject *MrdbConnection_escape_string(MrdbConnection *self,
|
|||||||
if (!PyArg_ParseTuple(args, "O!", &PyUnicode_Type, &string))
|
if (!PyArg_ParseTuple(args, "O!", &PyUnicode_Type, &string))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
from= PyUnicode_AsUTF8AndSize(string, (Py_ssize_t *)&from_length);
|
from= (char *)PyUnicode_AsUTF8AndSize(string, (Py_ssize_t *)&from_length);
|
||||||
to= (char *)alloca(from_length * 2 + 1);
|
to= (char *)alloca(from_length * 2 + 1);
|
||||||
to_length= mysql_real_escape_string(self->mysql, to, from, from_length);
|
to_length= mysql_real_escape_string(self->mysql, to, from, (unsigned long)from_length);
|
||||||
new_string= PyUnicode_FromStringAndSize(to, to_length);
|
new_string= PyUnicode_FromStringAndSize(to, to_length);
|
||||||
return new_string;
|
return new_string;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ static int Mrdb_GetFieldInfo(MrdbCursor *self)
|
|||||||
mariadb_stmt_fetch_fields(self->stmt);
|
mariadb_stmt_fetch_fields(self->stmt);
|
||||||
|
|
||||||
if (self->is_named_tuple) {
|
if (self->is_named_tuple) {
|
||||||
int i;
|
unsigned int i;
|
||||||
if (!(self->sequence_fields= (PyStructSequence_Field *)
|
if (!(self->sequence_fields= (PyStructSequence_Field *)
|
||||||
PyMem_RawCalloc(field_count + 1,
|
PyMem_RawCalloc(field_count + 1,
|
||||||
sizeof(PyStructSequence_Field))))
|
sizeof(PyStructSequence_Field))))
|
||||||
@ -882,7 +882,7 @@ PyObject *MrdbCursor_scroll(MrdbCursor *self, PyObject *args,
|
|||||||
mysql_stmt_data_seek(self->stmt, new_position);
|
mysql_stmt_data_seek(self->stmt, new_position);
|
||||||
else
|
else
|
||||||
mysql_data_seek(self->result, new_position);
|
mysql_data_seek(self->result, new_position);
|
||||||
self->row_number= new_position;
|
self->row_number= (unsigned long)new_position;
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
@ -1022,7 +1022,7 @@ uint8_t MrdbCursor_executemany_fallback(MrdbCursor *self,
|
|||||||
goto error;
|
goto error;
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
if (i==0)
|
if (i==0)
|
||||||
rc= mysql_stmt_prepare(self->stmt, statement, len);
|
rc= mysql_stmt_prepare(self->stmt, statement, (unsigned long)len);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc= mysql_stmt_execute(self->stmt);
|
rc= mysql_stmt_execute(self->stmt);
|
||||||
Py_END_ALLOW_THREADS;
|
Py_END_ALLOW_THREADS;
|
||||||
|
Reference in New Issue
Block a user