运行以下程序时,我遇到了令人抓狂的语法错误。这是错误:
File "Create_the_database.py", line 64
^
SyntaxError: invalid syntax
这是代码(很长,但重复性很容易撇去):
import sqlalchemy
from sqlalchemy import *
engine = create_engine('sqlite:///Users/benscholz/Dropbox/OmniCloud/omnicloud/dev.db')
meta = MetaData()
createUsersTable()
createAccountsTable()
createPasswordsTable()
meta.bind = engine
meta.create_all(engine)
def createUsersTable():
print("creating User Table")
users = Table('users', metadata,
Column('id', Integer, primary_key = True),
Column('username', String, nullable = False),
Column('email_address', String, nullable = False),
Column('first_name', String),
Column('full_name', String),
Column('join_date', DateTime))
def createAccountsTable():
print("creating Accounts Table")
accounts = Table('accounts', metadata,
Column('user_id', ForeignKey('users.id')),
Column('facebook_username', String),
Column('email_username_1', String),
Column('email_username_2', String),
Column('email_username_3', String),
Column('email_username_4', String),
Column('email_username_5', String),
Column('twitter_username_1', String),
Column('twitter_username_2', String),
Column('twitter_username_3', String),
Column('klout_username', String),
Column('dropbox_username', String),
Column('box_username', String),
Column('flickr_username_1', String),
Column('flickr_username_2', String),
Column('instagram_username', String),
Column('disqus_username', String),
Column('stack_overflow_username', String))
def createPasswordsTable():
print("creating Passwords Table")
passwords = Table('passwords', metadata,
Column('user_id', ForeignKey('users.id')),
Column('facebook_pass', String),
Column('email_pass_1', String),
Column('email_pass_2', String),
Column('email_pass_3', String),
Column('email_pass_4', String),
Column('email_pass_5', String),
Column('twitter_pass_1', String),
Column('twitter_pass_2', String),
Column('twitter_pass_3', String),
Column('klout_pass', String),
Column('dropbox_pass', String),
Column('box_pass', String),
Column('flickr_pass_1', String),
Column('flickr_pass_2', String),
Column('instagram_pass', String),
Column('disqus_pass', String),
Column('stack_overflow_pass', String))
这个程序是64行,所以它似乎到了最后并期待......某事?
答案 0 :(得分:1)
在修好两件事后,它对我来说很好。
至于语法错误,我猜文件在最后一行有一些无效字符,无法在屏幕上打印。我的建议是删除最后一行,然后重新输入。