Querying MariaDB from python
Ervin Hegedüs
airween at gmail.com
Tue Oct 2 12:14:13 EDT 2018
Hi Tony,
On Tue, Oct 02, 2018 at 05:07:38PM +0100, Tony van der Hoff wrote:
> On 02/10/18 16:47, Ervin Hegedüs wrote:
> > hi,
> >
> > now rows will looks like this:
> > ({'id':...,...},{'id':...,}...)
>
> Thanks Ervin, but:
>
> cursor = cnx.cursor(pymysql.cursors.DictCursor)
> NameError: name 'pymysql' is not defined
>
> I have been using the mysql.connector module, which seems to be the
> "official" python interface. I hadn't spotted the pymysql module. Is the
> consensus here that pymysql is the preferred connector?
well, since I'm using Python3, I didn't use "old" MySQLdb python
module, I switched to pymysql - but as I know they are
compatible, so you can use:
cnx.cursor(MySQLdb.cursors.DictCursor)
I don't know about "mysql.connector" module yet - but it doesn't
mean that it doesn't existst :)
hth,
a.
More information about the Python-list
mailing list