Integration of _mysql and MySQLdb with XTA

43 views
Skip to first unread message

cam...@yahoo.com

unread,
Oct 6, 2018, 6:15:02 AM10/6/18
to PyMySQL Users
Dear All,
XTA (XA Transaction API, http://www.tiian.org/lixa/XTA.html) is a new API that has been developed inside the LIXA project to support two phase commit transactions in the context of FaaS (Function as a Service) and microservice oriented, polyglot applications.

The API already supports C and C++ languages; it aims to support many more, at the bare minimum Python, PHP and Java.
I'm currently working on supporting Python with PostgreSQL and MySQL, this mail thread is related to Python/MySQL.

XTA is implemented in C language and XTA for Python is generated using SWIG: I would like to repeat the approach for all the languages that provides drivers derived from MySQL C API

Now the request for help: XTA needs to enlist all the resource managers (here MySQL) to manage them using 2 phase commit, basically it requires a pointer (MYSQL *) that must be passed to MysqlXaResource constructor (http://www.tiian.org/lixa/manuals/xta/CPP/classxta_1_1MysqlXaResource.html) to create an XTA object associated to an already opened MySQL connection.


# initialize XTA environment
Xta_Init()

# create a new MySQL connection
# Note: using _mysql or MySQLdb functions
rm2 = MySQLdb.connect("localhost", "lixa", "", "lixa")
or
rm2 = _mysql.connect("localhost", "lixa", "", "lixa")

# create a new XTA Transaction Manager object
tm = TransactionManager()

# create an XA resource for MySQL
#
# how to retrieve MYSQL * from rm2 ?
xar2 = MysqlXaResource(rm2.???, "PostgreSQL", "dbname=testdb")


Looking at the last statement, the stack is:
- XTA native C library expects "MYSQL *" to register the connection handler
- XTA C++ wrapper expects "MYSQL *" as the first parameter to construct the object
- XTA Python (SWIG generated) wrapper expects a "SWIG generated" MYSQL * pointer (it can be changed with another well known type by means of "typemap" directive (https://github.com/tiian/lixa/blob/master/src/xta/python/xta.i )
- _mysql.connect() and MySQLdb.connect() do not provide me something equivalent to MYSQL *, at least it seems so to me.

Thanks in advance for your help.
Regards,
Ch.F.


Reply all
Reply to author
Forward
0 new messages