Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- cnx = mysql.connector.connect(user="user",
- password="password",
- host="111.111.111.11",
- database=connect)
- cursor = cnx.cursor()
- print("{} does exist".format(connect))
- with open("mySQL.sql") as f:
- code = compile(f.read(), "mySQL.sql", "exec")
- exec(code)
- cursor.close() # closes the cursor
- cnx.close() # closes the connection
- select id from tablename;
- code = compile(f.read(), "mySQL.sql", "exec")
- File "mySQL.sql", line 1
- select id from tablename;
- ^
- SyntaxError: invalid syntax
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement