Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65654 > unrolled thread
| Started by | Sam <lightaiyee@gmail.com> |
|---|---|
| First post | 2014-02-08 00:52 -0800 |
| Last post | 2014-02-09 08:40 -0200 |
| Articles | 8 — 4 participants |
Back to article view | Back to comp.lang.python
Why use _mysql module and not use MySQLdb directly? Sam <lightaiyee@gmail.com> - 2014-02-08 00:52 -0800
Re: Why use _mysql module and not use MySQLdb directly? Chris Angelico <rosuav@gmail.com> - 2014-02-08 20:00 +1100
Re: Why use _mysql module and not use MySQLdb directly? Asaf Las <roegltd@gmail.com> - 2014-02-08 03:09 -0800
Re: Why use _mysql module and not use MySQLdb directly? Chris Angelico <rosuav@gmail.com> - 2014-02-08 22:25 +1100
Re: Why use _mysql module and not use MySQLdb directly? Asaf Las <roegltd@gmail.com> - 2014-02-08 03:32 -0800
Re: Why use _mysql module and not use MySQLdb directly? Chris Angelico <rosuav@gmail.com> - 2014-02-08 22:42 +1100
Re: Why use _mysql module and not use MySQLdb directly? Asaf Las <roegltd@gmail.com> - 2014-02-08 04:09 -0800
Re: Why use _mysql module and not use MySQLdb directly? Marcel Rodrigues <marcelgmr@gmail.com> - 2014-02-09 08:40 -0200
| From | Sam <lightaiyee@gmail.com> |
|---|---|
| Date | 2014-02-08 00:52 -0800 |
| Subject | Why use _mysql module and not use MySQLdb directly? |
| Message-ID | <f3632548-db57-4357-8d01-03807861d851@googlegroups.com> |
I am writing my first python script to access MySQL database. With reference to http://mysql-python.sourceforge.net/MySQLdb.html#connection-objects Why is it advisable to use _mysql and not MySQLdb module directly?
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-08 20:00 +1100 |
| Message-ID | <mailman.6530.1391850062.18130.python-list@python.org> |
| In reply to | #65654 |
On Sat, Feb 8, 2014 at 7:52 PM, Sam <lightaiyee@gmail.com> wrote: > I am writing my first python script to access MySQL database. With reference to http://mysql-python.sourceforge.net/MySQLdb.html#connection-objects > > Why is it advisable to use _mysql and not MySQLdb module directly? Other way around. It's advisable to ignore _mysql, which is a fairly direct representation of the MySQL C API, and use MySQLdb instead. When you use MySQLdb, you can fairly easily switch over to another database engine (like PostgreSQL, which for most purposes is superior to MySQL anyway), without changing most of your code. The only reason to use _mysql would be if you need your code to be really similar to other MySQL code in some other language - maybe you're using Python to prototype a C application, and want to keep everything as close as you can. Normally, use the higher level module. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Asaf Las <roegltd@gmail.com> |
|---|---|
| Date | 2014-02-08 03:09 -0800 |
| Message-ID | <429f41e0-7fe8-4792-82f2-e438917a3add@googlegroups.com> |
| In reply to | #65654 |
On Saturday, February 8, 2014 10:52:36 AM UTC+2, Sam wrote: > I am writing my first python script to access MySQL database. > With reference to http://mysql-python.sourceforge.net/MySQLdb.html#connection-objects > Why is it advisable to use _mysql and not MySQLdb module directly? I used this one from Oracle and it was OK for simple test case and supports from 2.6 till 3.3: http://dev.mysql.com/doc/connector-python/en/index.html https://pypi.python.org/pypi/mysql-connector-python/1.1.5 yet there is page to bunch of others but i have never tried them: https://wiki.python.org/moin/MySQL Are there hidden issues about Oracle provided connector?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-08 22:25 +1100 |
| Message-ID | <mailman.6536.1391858718.18130.python-list@python.org> |
| In reply to | #65667 |
On Sat, Feb 8, 2014 at 10:09 PM, Asaf Las <roegltd@gmail.com> wrote: > I used this one from Oracle and it was OK for simple test case and > supports from 2.6 till 3.3: > http://dev.mysql.com/doc/connector-python/en/index.html > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > > yet there is page to bunch of others but i have never tried them: > https://wiki.python.org/moin/MySQL > > Are there hidden issues about Oracle provided connector? I don't know. The first thing I'd look for is compatibility with the Python Database API. I flipped through the docs without finding anything obvious either direction; it seems to be similar, at least, but it's not declaring that it complies, which I would have thought would be an important boast. Also check for platform availability. If one package is available on Linux, Mac, Windows, and myriad others, and the other is available on only a few platforms, that's a mark in favour of the first. But I suspect that won't be an issue with most of what you'll find. My suspicion, without any proof, is that it's going to come down to a matter of taste, or maybe some tangential features. The core will most likely work just fine with pretty much any module you choose to use. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Asaf Las <roegltd@gmail.com> |
|---|---|
| Date | 2014-02-08 03:32 -0800 |
| Message-ID | <145766f5-6e5f-40c7-be92-3adbf1015731@googlegroups.com> |
| In reply to | #65669 |
On Saturday, February 8, 2014 1:25:15 PM UTC+2, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 10:09 PM, Asaf Las <r...@gmail.com> wrote: > > > I used this one from Oracle and it was OK for simple test case and > > supports from 2.6 till 3.3: > > http://dev.mysql.com/doc/connector-python/en/index.html > > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > yet there is page to bunch of others but i have never tried them: > > https://wiki.python.org/moin/MySQL > > > Are there hidden issues about Oracle provided connector? > > I don't know. The first thing I'd look for is compatibility with the > Python Database API. I flipped through the docs without finding > anything obvious either direction; it seems to be similar, at least, > but it's not declaring that it complies, which I would have thought > would be an important boast. > Also check for platform availability. If one package is available on > Linux, Mac, Windows, and myriad others, and the other is available on > only a few platforms, that's a mark in favour of the first. But I > suspect that won't be an issue with most of what you'll find. > > My suspicion, without any proof, is that it's going to come down to a > matter of taste, or maybe some tangential features. The core will most > likely work just fine with pretty much any module you choose to use. > ChrisA Hi Chris The doc says https://pypi.python.org/pypi/mysql-connector-python/1.1.5 MySQL driver written in Python which does not depend on MySQL C client libraries and implements the DB API v2.0 specification (PEP-249). it is pure one and confirms to PEP. though of course i can't say for sure any side impact. /Asaf
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-08 22:42 +1100 |
| Message-ID | <mailman.6537.1391859760.18130.python-list@python.org> |
| In reply to | #65671 |
On Sat, Feb 8, 2014 at 10:32 PM, Asaf Las <roegltd@gmail.com> wrote: > Hi Chris > The doc says > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > MySQL driver written in Python which does not depend on MySQL C > client libraries and implements the DB API v2.0 specification (PEP-249). Ah. And that links to dev.mysql.com, so it's presumably the same thing... would be nice if they'd say that on their own site. That's what I was looking for, anyhow. Confirms the suspicion. There may well be performance differences between pure-Python implementations and ones that go via C, but having used a pure-high-level-language implementation of PostgreSQL's wire protocol (granted, that was Pike, which is a somewhat higher performance language than Python, but same difference), I can assure you of what ought to be obvious anyway: that performance is dominated by the server's throughput and thus (usually) by disk speed. So it's going to be pretty much the same with all of them; look for ancillary features that might make your life easier, otherwise pick whichever you like. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Asaf Las <roegltd@gmail.com> |
|---|---|
| Date | 2014-02-08 04:09 -0800 |
| Message-ID | <58c461a7-bf08-4258-af29-2b1d7778a85c@googlegroups.com> |
| In reply to | #65672 |
On Saturday, February 8, 2014 1:42:30 PM UTC+2, Chris Angelico wrote: > On Sat, Feb 8, 2014 at 10:32 PM, Asaf Las <r...@gmail.com> wrote: > > > Hi Chris > > The doc says > > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > MySQL driver written in Python which does not depend on MySQL C > > client libraries and implements the DB API v2.0 specification (PEP-249). > > Ah. And that links to dev.mysql.com, so it's presumably the same > thing... would be nice if they'd say that on their own site. That's > what I was looking for, anyhow. Confirms the suspicion. > > There may well be performance differences between pure-Python > implementations and ones that go via C, but having used a > pure-high-level-language implementation of PostgreSQL's wire protocol > (granted, that was Pike, which is a somewhat higher performance > language than Python, but same difference), I can assure you of what > ought to be obvious anyway: that performance is dominated by the > server's throughput and thus (usually) by disk speed. So it's going to > be pretty much the same with all of them; look for ancillary features > that might make your life easier, otherwise pick whichever you like. > > ChrisA Hmmm, they say : http://dev.mysql.com/doc/connector-python/en/connector-python-introduction.html "MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the Python DB API version 2.0. It is written in pure Python and does not have any dependencies except for the Python Standard Library..." i guess with Oracle connector there could be one advantage - they will try to be most compliant to their product in every aspect as they would raiser promote their DB instead of discouraging from it. /Asaf
[toc] | [prev] | [next] | [standalone]
| From | Marcel Rodrigues <marcelgmr@gmail.com> |
|---|---|
| Date | 2014-02-09 08:40 -0200 |
| Message-ID | <mailman.6577.1391942408.18130.python-list@python.org> |
| In reply to | #65673 |
[Multipart message — attachments visible in raw view] — view raw
Another option is PyMySQL [1]. It's developed in the open at GitHub [2]. It's pure Python, compatible with both Python 2 and Python 3. It's DB-API 2 compliant. It also implements some non-standard bits that are present in MySQLdb, in order to be compatible with legacy code, notably Django (personally, I consider the use of non-standard API from a DB adapter a bug, but while the big projects don't fix it, we have to work around it). [1] https://pypi.python.org/pypi/PyMySQL [2] https://github.com/PyMySQL/PyMySQL 2014-02-08 10:09 GMT-02:00 Asaf Las <roegltd@gmail.com>: > On Saturday, February 8, 2014 1:42:30 PM UTC+2, Chris Angelico wrote: > > On Sat, Feb 8, 2014 at 10:32 PM, Asaf Las <r...@gmail.com> wrote: > > > > > Hi Chris > > > The doc says > > > https://pypi.python.org/pypi/mysql-connector-python/1.1.5 > > > MySQL driver written in Python which does not depend on MySQL C > > > client libraries and implements the DB API v2.0 specification > (PEP-249). > > > > Ah. And that links to dev.mysql.com, so it's presumably the same > > thing... would be nice if they'd say that on their own site. That's > > what I was looking for, anyhow. Confirms the suspicion. > > > > There may well be performance differences between pure-Python > > implementations and ones that go via C, but having used a > > pure-high-level-language implementation of PostgreSQL's wire protocol > > (granted, that was Pike, which is a somewhat higher performance > > language than Python, but same difference), I can assure you of what > > ought to be obvious anyway: that performance is dominated by the > > server's throughput and thus (usually) by disk speed. So it's going to > > be pretty much the same with all of them; look for ancillary features > > that might make your life easier, otherwise pick whichever you like. > > > > ChrisA > > Hmmm, they say : > > http://dev.mysql.com/doc/connector-python/en/connector-python-introduction.html > > "MySQL Connector/Python enables Python programs to access MySQL databases, > using an API that is compliant with the Python DB API version 2.0. It > is written in pure Python and does not have any dependencies except for > the Python Standard Library..." > > i guess with Oracle connector there could be one advantage - they will > try to be most compliant to their product in every aspect as they would > raiser promote their DB instead of discouraging from it. > > /Asaf > -- > https://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web