1

This is what i am trying to do:

cursor.execute("CREATE DATABASE testing")
cursor.execute("USE testing")
cursor.execute("CREATE TABLE Contract(mEnd varchar(7))")    
cursor.execute("CREATE TABLE User(uName varchar(15)")

When I run the python script using MySQLdb it only creates the first table and it ignores all the other lines of code.

2 Answers 2

1

) is missing in your last statement. Though you really don't want to do it this way.

Sign up to request clarification or add additional context in comments.

6 Comments

If this is the reason, why Contract is not being created according to the OP?
@iced what would be a better approach?
"but when I run the python script it only creates the first table and it ignores all the other lines of code." (c) (tm). and yes, this is the reason. As mysql isn't real database, virtually all libs are configuring autocommit by default.
seems dead. well, anyway, statement's true - pick up any migration framework you fancy and use it.
FYI, south is there specifically for django projects and it became a base for the Django migration framework introduced in 1.7 - which is why it is dying.
|
0

Try the following

execute = ["CREATE DATABASE testing","USE testing","CREATE TABLE Contract(mEnd varchar(7))","CREATE TABLE User(uName varchar(15))"]
for i in execute:
    cussor.execute(i)
    cussor.commit()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.