Basic MySQL header use
2016-05-31 06:26:16 GMT
I want to do is get a dump of a MySQL table into python as quickly as possible, but most python mysql connectors seem to be relatively slow. So I'm trying Cython.
In theory, the C side has a nice API and is very simple: see "retrieving data from the database" section of here: http://zetcode.com/db/mysqlc/. What I'm finding hard (as a C/Cython newbie) is getting all of the libraries/links correct, and even the most basic thing to run.
So far, I have the following mymysql.pyx
ctypedef struct MYSQL:
unsigned char *connector_fd;
char *info, *db;
#const struct charset_info_st *charset;
unsigned long thread_id;
unsigned long packet_length;
unsigned int port;
unsigned long client_flag,server_capabilities;
unsigned int protocol_version;
unsigned int field_count;
unsigned int server_status;
unsigned int server_language;
unsigned int warning_count;
#struct st_mysql_options options;
#enum mysql_status status;
void *unused2, *unused3, *unused4, *unused5;
#const struct st_mysql_methods *methods;
MYSQL * mysql_init(MYSQL *mysql)
cdef MYSQL *con = mysql_init(NULL)
which compiles using:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
extensions = [
extra_compile_args=["-L/usr/lib64", "-lmysqlclient", "-lpthread", "-lz", "-lm", "-lssl", "-lcrypto", "-ldl", "-I/usr/include/mysql"] # from $(mysql_config --libs --cflags)
However, when I try to import the basic 'do' function, I get:
Is the first place to start completing the ctypedef of MYSQL? I haven't because I don't even know if I need to include it at all, and it's proving quite painful as there seem to be quite a few other things I need to define to fully define MYSQL.
Tips would be most appreciated,
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users+unsubscribe <at> googlegroups.com.
For more options, visit https://groups.google.com/d/optout.