mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-04 08:04:45 +00:00
Merge branch 'master' into rush_master
# Conflicts: # setup.py
This commit is contained in:
@ -1,2 +1,10 @@
|
||||
# mariadb-connector-python
|
||||
MariaDB Connector/Python
|
||||
|
||||
This package contains a MariaDB client library for connecting to MariaDB and MySQL
|
||||
database servers based on PEP-249.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Python 3.6 (or newer). Older Python 3 versions might work, but aren't tested.
|
||||
* MariaDB Connector/C, minimum required version is 3.1
|
||||
|
@ -31,14 +31,13 @@ def get_config():
|
||||
connector_key = OpenKey(local_reg,
|
||||
'SOFTWARE\\MariaDB Corporation\\MariaDB Connector C 64-bit',
|
||||
access=KEY_READ | KEY_WOW64_64KEY)
|
||||
|
||||
cc_version = QueryValueEx(connector_key, "Version")
|
||||
if cc_version[0] < required_version:
|
||||
print(
|
||||
"MariaDB Connector/Python requires MariaDB Connector/C >= %s (found version: %s") \
|
||||
% (required_version, cc_version[0])
|
||||
sys.exit(2)
|
||||
cc_instdir = QueryValueEx(Key, "InstallDir")
|
||||
cc_instdir = QueryValueEx(connector_key, "InstallDir")
|
||||
|
||||
except:
|
||||
print("Could not find InstallationDir of MariaDB Connector/C. "
|
||||
|
18
setup.py
18
setup.py
@ -13,10 +13,26 @@ cfg = get_config()
|
||||
|
||||
setup(name='mariadb',
|
||||
version='0.9.1',
|
||||
classifiers = [
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: Console',
|
||||
'Environment :: MacOS X',
|
||||
'Environment :: Win32 (MS Windows)',
|
||||
'Environment :: Posix',
|
||||
'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
|
||||
'Programming Language :: C',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: MacOS',
|
||||
'Operating System :: POSIX',
|
||||
'Intended Audience :: End Users/Desktop',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: System Administrators',
|
||||
'Topic :: Database'
|
||||
],
|
||||
description='Python MariaDB extension',
|
||||
author='Georg Richter',
|
||||
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',
|
||||
|
@ -169,7 +169,7 @@ void field_fetch_fromtext(MrdbCursor *self, char *data, unsigned int column)
|
||||
unsigned long utf8len;
|
||||
|
||||
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)
|
||||
self->fields[column].max_length= utf8len;
|
||||
break;
|
||||
@ -237,7 +237,7 @@ void field_fetch_callback(void *data, unsigned int column, unsigned char **row)
|
||||
long long l= sint8korr(*row);
|
||||
self->values[column]= (self->fields[column].flags & UNSIGNED_FLAG) ?
|
||||
PyLong_FromUnsignedLongLong((unsigned long long)l) :
|
||||
PyLong_FromLong(l);
|
||||
PyLong_FromLongLong(l);
|
||||
*row+= 8;
|
||||
break;
|
||||
}
|
||||
@ -368,7 +368,7 @@ void field_fetch_callback(void *data, unsigned int column, unsigned char **row)
|
||||
length= mysql_net_field_length(row);
|
||||
|
||||
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)
|
||||
self->fields[column].max_length= utf8len;
|
||||
*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));
|
||||
return 1;
|
||||
}
|
||||
param->indicator= MrdbIndicator_AsLong(column);
|
||||
param->indicator= (char)MrdbIndicator_AsLong(column);
|
||||
param->value= NULL; /* you can't have both indicator and value */
|
||||
} else if (column == Py_None)
|
||||
{
|
||||
@ -559,7 +559,7 @@ static uint8_t mariadb_get_parameter_info(MrdbCursor *self,
|
||||
return 1;
|
||||
}
|
||||
param->buffer_type= pinfo.type;
|
||||
bits= pinfo.bits;
|
||||
bits= (uint32_t)pinfo.bits;
|
||||
}
|
||||
|
||||
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.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;
|
||||
|
||||
if (!(self->array_size= PyList_Size(data)))
|
||||
if (!(self->array_size= (uint32_t)PyList_Size(data)))
|
||||
{
|
||||
mariadb_throw_exception(self->stmt, Mariadb_InterfaceError, 1,
|
||||
"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)
|
||||
self->param_count= PyTuple_Size(obj);
|
||||
self->param_count= (uint32_t)PyTuple_Size(obj);
|
||||
if (!self->param_count ||
|
||||
self->param_count != PyTuple_Size(obj))
|
||||
{
|
||||
@ -695,7 +695,7 @@ uint8_t mariadb_check_execute_parameters(MrdbCursor *self,
|
||||
{
|
||||
uint32_t i;
|
||||
if (!self->is_prepared)
|
||||
self->param_count= PyTuple_Size(data);
|
||||
self->param_count= (uint32_t)PyTuple_Size(data);
|
||||
|
||||
if (!self->param_count)
|
||||
{
|
||||
|
@ -946,7 +946,7 @@ static int MrdbConnection_setdb(MrdbConnection *self, PyObject *db,
|
||||
PyErr_SetString(PyExc_TypeError, "Argument must be string");
|
||||
return -1;
|
||||
}
|
||||
schema= PyUnicode_AsUTF8(db);
|
||||
schema= (char *)PyUnicode_AsUTF8(db);
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS;
|
||||
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))
|
||||
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_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);
|
||||
return new_string;
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ static int Mrdb_GetFieldInfo(MrdbCursor *self)
|
||||
mariadb_stmt_fetch_fields(self->stmt);
|
||||
|
||||
if (self->is_named_tuple) {
|
||||
int i;
|
||||
unsigned int i;
|
||||
if (!(self->sequence_fields= (PyStructSequence_Field *)
|
||||
PyMem_RawCalloc(field_count + 1,
|
||||
sizeof(PyStructSequence_Field))))
|
||||
@ -882,7 +882,7 @@ PyObject *MrdbCursor_scroll(MrdbCursor *self, PyObject *args,
|
||||
mysql_stmt_data_seek(self->stmt, new_position);
|
||||
else
|
||||
mysql_data_seek(self->result, new_position);
|
||||
self->row_number= new_position;
|
||||
self->row_number= (unsigned long)new_position;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
@ -1022,7 +1022,7 @@ uint8_t MrdbCursor_executemany_fallback(MrdbCursor *self,
|
||||
goto error;
|
||||
Py_BEGIN_ALLOW_THREADS;
|
||||
if (i==0)
|
||||
rc= mysql_stmt_prepare(self->stmt, statement, len);
|
||||
rc= mysql_stmt_prepare(self->stmt, statement, (unsigned long)len);
|
||||
if (!rc)
|
||||
rc= mysql_stmt_execute(self->stmt);
|
||||
Py_END_ALLOW_THREADS;
|
||||
|
Reference in New Issue
Block a user