background preloader

Python - MySQL Database Access

Python - MySQL Database Access
The Python standard for database interfaces is the Python DB-API. Most Python database interfaces adhere to this standard. You can choose the right database for your application. Python Database API supports a wide range of database servers such as − GadFlymSQLMySQLPostgreSQLMicrosoft SQL Server 2000InformixInterbaseOracleSybase Here is the list of available Python database interfaces: Python Database Interfaces and APIs .You must download a separate DB API module for each database you need to access. The DB API provides a minimal standard for working with databases using Python structures and syntax wherever possible. Importing the API module.Acquiring a connection with the database.Issuing SQL statements and stored procedures.Closing the connection We would learn all the concepts using MySQL, so let us talk about MySQLdb module. What is MySQLdb? MySQLdb is an interface for connecting to a MySQL database server from Python. How do I Install MySQLdb? #! Database Connection Example #! #! #! #! #! #! #!

Getting Started :: MySQL Connectivity With Python :: Dev Shed In the words of its author, MySQLdb is "a thread-compatible interface to the popular MySQL database server that provides the Python database API." Developed by Andy Dustman, this module is needed for MySQL database connectivity under Python. The first thing to do is make sure that you have the MySQLdb module installed on your Python development system. The easiest way to check this via the interactive Python command line interpreter - as the following example demonstrates: Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import MySQLdb Traceback (innermost last): File "<stdin>", line 1, in ? ImportError: No module named MySQLdb >>> If you see something like the error message above, you can safely assume that the module is not installed on your system. $ tar -xzvf MySQL-python-0.9.2.tar.gz $ cd MySQL-python-0.9.2 $ python build $ python install

Exporting data from MS Access 2003 to MySQL | Packt Publishing Technical & IT Book Store Exclusive offer: get 50% off this eBook here Choosing an Open Source CMS: Beginner's Guide — Save 50% Find the best CMS and start working with it to create web sites, blogs, communities, e-commerce sites, and intranets by Dr. Most businesses use a software mix in their IT arsenal that makes business sense to them. Introduction It is assumed that you have a working copy of MySQL which you can use to work with this article. You need to follow the steps indicated here: Create a database in MySQL to which you will export a table from Microsoft Access 2003Create a ODBC DSN that helps you connecting Microsoft Access to MySQLExport the table or tablesVerify the exported items Creating a database in MySQL You can create a database in MySQL by using the command 'Create Database' in MySQL or using a suitable graphic user interface such as MySQL workbench. Listing 1: Login and create a database Microsoft Windows XP [Version 5.1.2600](C) Copyright 1985-2001 Microsoft Corp. C:>cd xamppmysqlbin mysql> Summary