MySQL Forums
Forum List  »  Connector/Python

Re: creating a database using python
Posted by: duccio volpi
Date: November 27, 2008 01:25PM

You just need to connect without the parameter "db".
Then you can execute the "create" query.
You can olso use the query "USE db_name" to say what database you are going to use.

This code works to me:

db=MySQLdb.connect(user='root')
c=db.cursor()
c.execute('CREATE DATABASE pippo')


This is the link with sql manual:
http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html
The "USE" statement is in "SQL Utility Statements"

Options: ReplyQuote


Subject
Written By
Posted
Re: creating a database using python
November 27, 2008 01:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.