<br><br><div><span class="gmail_quote">On 5/17/06, <b class="gmail_sendername">Philippe Martin</b> <<a href="mailto:pmartin@snakecard.com">pmartin@snakecard.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
John Salerno wrote:<br><br>> Since the connect method of mysqldb requires a database name, it seems<br>> like you can't use it without having a database already created. So is<br>> there a way to connect to your mysql server (without a specified
<br>> database) in order to create a new database (i.e., the CREATE DATABASE<br>> query)?<br>><br>> Thanks.<br><br>I'm no expert but: can't you spawn mysql with a script/scheme ?<br><br>Philippe<br><br></blockquote>
</div>MySQLdb.connect does not require a database name. ie.:<br><br>>>> import MySqlDB<br clear="all">>>> db = MySQLdb.connect(host='localhost', user='root', passwd='xxxx')<br>>>> csr = db.cursor
()<br>>>> csr.execute('''show databases''')<br>6L<br>>>> for d in csr.fetchall():<br>    print d<br><br>('cc',)<br>('cc_41',)<br>('mysql',)<br>('purchaseorder',)<br>('test',)<br>('xsldb',)<br>>>> 
csr.execute('''create database newdb''')<br>1L<br>>>> csr.execute('''show databases''')<br>7L<br>>>> for d in csr.fetchall():<br>    print d<br><br>('cc',)<br>('cc_41',)<br>('mysql',)<br>('newdb',)<br>('purchaseorder',)
<br>('test',)<br>('xsldb',)<br>>>> <br><br>Later,<br>Lou<br>-- <br>Artificial Intelligence is no match for Natural Stupidity