[Tutor] Creating MySQL table
Don Parris
gnumathetes at gmail.com
Tue Jul 19 00:27:01 CEST 2005
On 7/18/05, Bernard Lebel <3dbernard at gmail.com> wrote:
> Hello,
>
> How do I create a MySQL table in Python?
>
> Here is what I'm trying:
>
>
> import MySQLdb as sql
>
> def connect2db():
> return sql.connect( blah blah blah )
>
>
> oConnection = connect2db()
> oCursor = oConnection.cursor()
>
>
> sQuery = "CREATE TABLE '3DPipeline'.'TB_MT_NAME' (;\
> 'ID' INTEGER UNSIGNED CHARACTER SET latin1 COLLATE latin1_swedish_ci
> NOT NULL AUTO_INCREMENT,
> 'text' TINYTEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
> PRIMARY KEY('ID')
> )
O.k., it looks like 3DPipeline is your database name, and TB_MT_NAME
is your table name. Your single quotes, if needed at all, most likely
need to look like:
'3DPipeline.TB_MT_NAME'(\
fieldone key1 key2 key3\
fieldtwo key1 key2 key3\
fieldthree key1 key2 key3
);
If you're using the backslash for line continuation, you need to add
the "\" at the end of each line in your SQL statement.
Hope this is a bit more helpful.
--
DC Parris GNU Evangelist
http://matheteuo.org/
gnumathetes at gmail.com
Free software is like God's love -
you can share it with anyone anywhere anytime!
More information about the Tutor
mailing list