Filter löschen
Filter löschen

Setting a Row Factory for SQLite Database Transactions Using Python

4 Ansichten (letzte 30 Tage)
Bob S
Bob S am 5 Nov. 2020
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?

Antworten (0)

Kategorien

Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by