MySQL & Python

Peter Decker pydecker at gmail.com
Thu Sep 15 10:37:06 EDT 2005


On 9/15/05, Ed Hotchkiss <edhotchkiss at gmail.com> wrote:

> I am trying to create a simple script to access a MySQL DB. 
> The Module for MySQL looks very easy, however I do not understand one thing
> ... 
>   
> In ASP, you can just create a new DB with Access. In MySQL, how do I create
> a database to start playing with? I see all of the commands to edits tables
> and values and move a cursor, but I do not see how I actually create THE
> INITIAL DB, any help would be appreciated. thanks. 

If you connect as a user who has database creation privileges on the
server, running:

cursor.execute("CREATE DATABASE FooBar")

will create a new database named 'FooBar' on the server. You will then
need to call:

cnnct.select_db("FooBar")

to change your connection to the new database.
-- 

# p.d.



More information about the Python-list mailing list