creating a database using python
Hi,
I just want to ask something from this code.
import MySQLdb
db = MySQLdb.connect(host="localhost", user="joe", passwd="secret",db="db56a")
cursor = db.cursor()
cursor.execute("SELECT * FROM animals")
In the code, I first Import the MySQLdb. Afterwhich I made a connection. But in order for me to make a connection, I must first have a database named db56a. Or else it will tell that db56a doesn't exist. Is there anyway that I can create a database before making a connection? Because what I need is a user to input the name of the database he/she wants to make. Then with the name, I could create already the database.
so my query will be like:
cursor.execute("create database %s" %database_name)
will it be possible?
Thanks,
Pat
Edited 1 time(s). Last edit at 11/24/2008 09:55AM by Patrice Anne Sanchez.
Subject
Written By
Posted
creating a database using python
November 24, 2008 09:53AM
November 24, 2008 01:28PM
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.