Effacer les filtres
Effacer les filtres

Setting a Row Factory for SQLite Database Transactions Using Python

4 vues (au cours des 30 derniers jours)
Bob S
Bob S le 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?

Réponses (0)

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by