why Python is required to install Cassandra - python

To install cassandra DB, python is required. Why is that so.?
What role Python plays in cassandra during installation and after(Is it for Driver connections?, or for cqlsh? because I see some python related files in cqlshlib folder)?
Cassandra is also a DB like others mongodb or mysql, oracle(of course some these are not noSQL and not distributed).

Because the cqlsh is written in Python...

Related

Installing postgresql db together with python package

I wrote a python script that requires the use of a postgresql DB. For test purpose, I installed the postgresql DB manually, and the DB that comes with that. The script connects to it and make its job.
My question is about packaging : what is the best solution for the user to install this script, along with the DB and its schema juste by typing pip install xxx ?
Is that possible ?
Thanks
Postgres is great but often you can get away with SQLite. It's part of the standard library and comes bundled with Python

what is Python 2.x database interface?

I am re-writng a perl program using python. In the perl program, it’s using perl database interface (DBI) to perform Oracle database operations. For example, DBI->connect to connect a database, and then prepare() the sql query and then execute() the query and fetch() results. I am wondering if Python has similar official module or other means to do the same things? I am using python 2.4 and 2.6 on two different RHEL 6.3 envs. Thanks in advance!
For SQLite3, there is the built-in sqlite3 module: http://docs.python.org/2/library/sqlite3.html
For PostgreSQL, there is psycopg2: http://initd.org/psycopg/
For MySQL, there is MySQLdb: http://mysql-python.sourceforge.net/MySQLdb.html
For MS SQL Server, there is pyodbc: http://code.google.com/p/pyodbc/
...or http://code.google.com/p/pymssql/
For Oracle:
https://wiki.python.org/moin/Oracle
http://www.oracle.com/technetwork/articles/dsl/python-091105.html
http://cx-oracle.sourceforge.net
PEP249, which #falsetru has mentioned, is more like an abstract description of a what a the API of a standards-conformant Python DB driver should look like. It is however in a way similar to DBI in that many (if not most or all) DB drivers for Python do have a very similar API, just like how DBI allows you to connect to many RDBMSes using a uniform API.
PLUG: take a look at Pony ORM also—it's an awesome new ORM with Oracle support: http://ponyorm.com.
Currently Pony supports 4 types of databases: 'sqlite', 'mysql', 'postgresql' and 'oracle'
It supports Python versions 2.5 or greater, but you can just use pythonz, pyenv to easily install any Python version without root privileges, or Conda.

MySQL connector

I am trying to build a tool that one step of it is connecting to MySQL database.
Just I am so confused about ODBC. If I want to build a cross platform connector by python, should I use python connector or ODBC connector?
I know JDBC, but ODBC stands for Open Database Connectivity. It looks like more compatible.
Could anyone help me clarify that? Thank you very much.
Python has its own DB API v2.0 abstraction layer to connect to databases (it serves the same purpose of ODBC or JDBC but for Python). You should use one of the DB API v2.0 compliant oursql, MySQLdb or PyMySQL packages to connect to MySQL from Python. All these packages are cross platform and will work on Linux, Windows and MacOS X. oursql, and MySQLdb are wrappers for libmysql and PyMySQL is a pure Python implementation.
Note that there are DB API v2.0 implementations (like pyodbc) that provide ODBC connectivity, so conceptually you could connect to MySQL via ODBC, but this would have inferior performance than the above mentioned "native" drivers because of the extra abstraction layers.

Querying a MySQL database with Python without installing MySQL

I'd like to query a MySQL database using Python, but evidently the MySQLdb package requires a huge toolchain of MySQL stuff to be separately installed.
How can I query a MySQL database using a Python script without installing a bunch of unnecessary MySQL stuff, including conferring MySQL server capability on the client machine?
I don't love Perl, but it appears that the DBI package allows a Perl script to interface with MySQL without any MySQL stuff external to the package. I'm looking for something similar for Python.
You need to find a pure mysql python library. I have seen a couple over the last couple months. A quick google search yoelded pymysql. It has a large following on github. It looks promising. Pymysql is a pure python mysql client.
https://github.com/petehunt/PyMySQL
MySQLdb is just one of the available database drivers. It requires all that extra installation stuff, because it compiles c extensions and is one of the faster options.
There are a handful of other database drivers, some of which are pure-python.
The SqlAlchemy project has one of the more up-to-date collections of database drivers:
http://docs.sqlalchemy.org/en/latest/core/engines.html
PyMysql is a pure python driver, so it won't need to be built against the local MySql library.

Uploading a mysql database to a webserver supporting python

I have a written a very small web-based survey using cgi with python(This is my first web app. ).The questions are extracted from a MySQL database table and the results are supposed to be saved in the same database. I have created the database along with its table locally. My app works fine on my local computer(localhost). To create db,table and other transaction with the MySQL i had to do import MySQLdb in my code.
Now I want to upload everything on my personal hosting. As far as I know my hosting supports Python,CGI and has MySQL database. And I know that I have to change some parameters in the connection string in my code, so I can connect to the database, but I have two problems:
I remember that I installed MySQLdb as an extra to my Python, and in my code i am using it, how would I know that my hosting's python interpretor has this installed, or do I even need it, do I have to use another library?
How do I upload my database onto my hosting?
Thanks
If you have shell access, you can fire up the python interpreter by running python and type import MySQLdb at the >>> prompt. If you get no errors in return, then its installed.
Likewise, if you have shell access, this page will help you with importing and exporting using the mysql command. I found it by googleing "import export mysql".
You can write a simple script like
import MySQLdb and catch any errors
to see if the required package is
installed. If this fails you can ask
the hosting provider to install your
package, typically via a ticket
The hosting providers typically also provide URL's to connect to the MySQL tables they provision for you, and some tools like phpmyadmin to load database dumps into the hosted MySQL instance
To check if MySQLdb library is installed on your hosting, simply open a python shell and type: import MySQLdb. If everthing goes ok, you're readt to go. If you get: ImportError: No module named MySQLdb, that means the the library is not installed and you nedd to install it.
You need that library or some library that provides similar support, because Python does not support native access to MySQL databases.
To transfer you database to your hosting check mysqldump.

Categories