How to use complex SQL scripts with python -
i write sp inside mysql , excute call statement. looking write in python instead. got stuck using sql script on multiple lines.
conn = pyodbc.connect('dsn=mysql;pwd=xxxx') csr = conn.cursor() sql= 'select something, table foo=bar order foo ' csr.execute(sql) sqld = csr.fetchall()
heh, don't mind make proper answer.
string literals in triple quotes can include linebreaks , won't cause syntax errors. otherwise (with "string" or 'string') need include backslash before every linebreak make work. , experience, that's easy screw up. :)
as minor note, in python variables started lowercase letter, names starting capital letters being given classes.
so:
sql = """select something, table foo=bar order foo"""
Comments
Post a Comment