Is there official MySQL driver for Tornado Framework? - python

I'm on the point of architecting some socket-based API and i run into problem.
Is there are officially supported MySQL driver for Tornado Framework? I wood use cool and modern async from Python 3.4, but this one don't support MySQL for sure.
And yes, i'm notice couple drivers in https://github.com/tornadoweb/tornado/wiki/Links, but my problem is - this drivers is kind a old and they don't support Python 3.
Thanks!

You can refer to these links. this is git hub link of PyMySQL fork for Tornado: https://github.com/PyMySQL/Tornado-MySQL
this link is a short doc for MySQLdb DB-API connections: https://tornado.readthedocs.org/en/branch2.4/database.html
you can find the supported python version in this link: https://pypi.python.org/pypi/Tornado-MySQL
as mentioned in the comments you can also see MySQL driver for asyncio: https://github.com/aio-libs/aiomysql , http://aiomysql.readthedocs.org/en/latest/

Related

Is there a Python library for Oracle SQL?

I've been looking across the internet to find some sort of library that will connect an Oracle database to a Python script, but so far I have been unsuccessful. If anyone has found a great library for Oracle, preferably first party, then please give me documentation. I'm working on a project now that particularly needs this integration. I've already seen lots of documentation for MySQL, which is maintained by Oracle, but that's about it.
The library is cx_Oracle. It conforms to the Python DB API 2.0 specification with a number of additions and a couple of exclusions. The cx_Oracle creator is Anthony Tuininga. Since 2017 the cx_Oracle is manteined by Oracle and Anthony Tuininga joined to Oracle and making maintaining the driver his full time job.
The lib have a good documentation and are frequently updated. There are a bunch of samples on cx_Oracle github.
Oracle provides the python library cx_Oracle. Like everything else produced by Oracle, the documentation leaves some to be desired and the drivers are an absolute pain in the ass, but it works.

What are the differences between PyHDB and the hdbcli python package from the HANA client?

In order to work with HANA in python, I've always used the pretty old python 2.6.4 that came with the HANA client. There are ways to get it working with other python versions, too, but they seem to by very hacky.
Now I've found the very promising-looking PyHDB project on Github, which seems to do the same job being installed more easy and working with newer Python versions, too.
Which features won't work with PyHDB that worked with the HANA python?
Are there performance drawbacks?
Edit:
Here is what I found using the module globals:
PyHDB is more thread-safe (threads may share connections here)
the parameter style is different (PyHDB: format; hdbcli: qmark, named)
Here an update on the current situation:
pyhdb supports Python 2.7, 3.3, 3.4, 3.5 and also PyPy on Linux, OSX
and Windows.
hdbcli has support for python 2.7 and python 3.4+ and is is fully supported and pushed by SAP.
Regarding performance:
executemany is an order of magnitude faster with hdbcli
The following blog post contains some further information:
https://blogs.sap.com/2017/07/26/sap-hana-2.0-sps02-new-feature-updated-python-driver/
The PyHDB is the younger brother of the node-hdb, both implementing the same protocol as ODBC based Python package hdbcli. The hdbcli Python client is a part of standard HANA installation but it does not belong to the list of officially supported interfaces for building HANA applications, to my knowledge.
The orientation for building PyHDB was therefore not the hdbcli client but the above mentioned protocol specification and the existing node-hdb implementation.
The detailed hdbcli/PyHDB cross-comparison is therefore not currently available but looking into the protocol specification and READMEs of PyHDB and node-hdb helps getting insight into connectors' features and the current coverage of the specification by both implementations.
Among these three HANA connectors, hdbcli, node-hdb and PyHDB, the PyHDB, being the youngest one, offers atm. the least features and capabilities, missing some features already available in node-hdb, like authentication methods or prepared statements for example. Looking into node-hdb source helps getting the rough estimate of efforts required for building the same in Python.
Rather than waiting for the full coverage of the protocol, which could take a while, the PyHDB is released "as is", but open for receiving input and requirements from projects and offering new features in that direction.
No performance drawbacks discovered so far.
Perhaps worth of mentioning here, the direct connectivity from Python and nodejs (GO should come soon) is also possible with ABAP, via SAP RFC protocol, via PyRFC and node-rfc connectors, which are counterparts of standard ABAP RFC connectors, available for Java and .NET as well.
pyhdb was deprecated in May 2021 and is no longer maintained. You can find its GitHub repo is archived (https://github.com/SAP-archive/PyHDB) and in read-only mode. Any open issues and pull requests were closed by the SAP maintainer #bsrdjan. hdbcli is now the recommended Python package for interacting with SAP HANA databases, although it's closed source with less documentation.
I recommend using sqlalchemy-hana, which is a SQLAlchemy dialect for SAP HANA databases. It can use hdbcli or pyhdb with a one-line change to the configuration, so you don't need to track down database driver documentation.

Interact with SQL database using only Python 2.4

I have a website on an Australian webhost. I have designed my website to allow people to login & their login details are stored in an SQLite3 database. I interact with the SQLite3 database using pythons SQLite3 module(found only in python2.5 & up)
My Problem: the webhost runs Python 2.4 so I cannot communicate with(query or modify) my SQLite3 database. The webhost will not allow me to install my own version of python or upload modules unless I upgrade to VPS.
What do you think are my options to still be able to work/interface with my SQL database? Do you know of way to interact with a SQL database using python modules from Python 2.4 or earlier?
Do you know of a python 2.4 module that will let me interact with an SQL database(can be MySQL, SQLite, etc.)?
There is a Python MySQL Module, called MySQLDB, which supports Python 2.3-2.7: http://sourceforge.net/projects/mysql-python/
The User Guide can be found here: http://mysql-python.sourceforge.net/MySQLdb.html
Check out pysqlite. It is the same module as in the newer python versions and I have used it no prob in 2.4 before.

Python & sql server

What is the best way to access sql server from python is it DB-API ?
Also could someone provide a such code using the DB-API how to connect to sql server from python and excute query ?
See pyodbc - Python Database API Specification v2.0 implementation. Works great.
Additionally you can use it with other databases. If using with SQL Server 2008, make sure you use Native Driver if you need to support new DATE data types.
See pymssql It is a DB-API module for MS Sql Server and would be the most pythonic way. The documentation includes examples.
If on a Windows OS you could also use OLEDB through COM which will not require any thing else to be installed on the client.
Also if you use Iron Python you can use the .Net APIs
Also could someone provide a such code using the DB-API
how to connect to sql server from python and excute query ?
This hello world snippet pretty much shows you the common way how to connect with SQL server in Python with an DBI 2.0 database interface module.
Disclaimer: I'm the developer of pypyodbc
ODBC + freetds + a python wrapper library for ODBC.

Setup Python environment on Windows

How do I setup a Python environment on windows computer so I can start writing and running Python scripts, is there an install bundle? Also which database should i use?
I should of mentioned that I am using this for web based applications. Does it require apache? or does it use another http server? What is the standard setup for Python running web apps?
Download the Python 2.6 Windows installer from python.org (direct link). If you're just learning, use the included SQLite library so you don't have to fiddle with database servers.
Most web development frameworks (Django, Turbogears, etc) come with a built-in webserver command that runs on the local computer without Apache.
Bundle: go with Activestate's Python, which bundles many useful win32-related libraries. It has no version 2.6 yet, but most code you'll find online refers to 2.5 and lower anyway.
Database: any of the popular open-source DBs are simple to configure. But as John already suggested, for simple beginning stuff just use SQLite which already comes bundled with Python.
Web server: depends on the scale. You can configure Apache, yes, but for trying simple things the following is a quite complete web server in Python that will also serve CGI scripts writte in Python:
import CGIHTTPServer
import BaseHTTPServer
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ["/cgi"]
PORT = 9999
httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
I strongly recommend ActiveState Python for python on windows development. It comes with Win32Com and various other goodies, has a mature and clean installer, a chm version of the docs and works really well. I use this all of the time.
As for a database, Activestate comes with odbc support, which plays very nicely with SQL server. I've also had it working with Sybase and DB2/400 (although the connection strings for the latter tend to be rather convoluted). For Oracle, I recommend CX_Oracle as the best interface library. Native drivers for most proprietary and open-source databases (such as MySQL and PostGreSQL) also exist. Recent versions of Python (from 2.5 onwards IIRC) come with SQLite bundled as standard.
Don't forget to install pywin32 after installing the official (command line) installer. This will define additional start menu items and the highly useful PythonWin IDE.
An installer for both is available at Activestate (no 2.6 yet). The Activestate distribution contains additional documentation.
Might I suggest taking a look at Karrigell? It's really a nice Python web framework if you don't require everything Django and Turbogears offers. It might be easier for you to work with web frameworks until you get comfortable with them.
For development, I recommend downloading the latest SPE IDE. It should provide you nearly all the tools you will need, plus it includes wxGlade for GUI development.
Django tutorial How to install Django provides a good example how a web-development Python environment may look.

Categories

Resources