Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import mysql.connector
  2. cnx = mysql.connector.connect(user="user",
  3.                               password="password",
  4.                               host="111.111.111.11",
  5.                               database=connect)
  6.  
  7.         cursor = cnx.cursor()
  8.         print("{} does exist".format(connect))
  9.  
  10.          with open("mySQL.sql") as f:
  11.              code = compile(f.read(), "mySQL.sql", "exec")
  12.              exec(code)
  13.  
  14.         cursor.close()  # closes the cursor
  15.         cnx.close()  # closes the connection
  16.  
  17. select id from tablename;
  18.  
  19. code = compile(f.read(), "mySQL.sql", "exec")
  20. File "mySQL.sql", line 1
  21. select id from tablename;
  22.        ^
  23. SyntaxError: invalid syntax
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement