Setting a Row Factory for SQLite Database Transactions Using Python

4 次查看(过去 30 天)
I am accessing a SQLite database using Python from Matlab:
>> dbFileName = 'myDatabase.db';
>> sql = py.importlib.import_module('sqlite3');
>> conn = sql.connect(dbFileName);
>> cur = conn.cursor()
% Followed by a SELECT command and a fetchone()
I want to use the row_factory py.sqlite3.Row. By default, the row_factory is set to py.None.
Outside of Matlab, from the Python prompt, I would simply do the following:
>>> con.row_factory = sql.Row
I tried the following from Matlab:
>> con.row_factory = py.sqlite3.Row;
however, the following Matlab error comes up:
Python Error: TypeError: function takes 2 arguments (0 given)
which is referring to py.sqlite3.Row. No luck in investigating sql.Row in the Python help.
Any ideas?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by