1. # File "import_ftp_users-v1.py", line 21, in <module>
  2. #    "VALUES (%s, %s, '(read)(write)(view)(delete)(resume)(share)(slideshow)(rename)(makedir)(deletedir)'", (row_number+offset, path))
  3. # File "/usr/lib/pymodules/python2.7/MySQLdb/cursors.py", line 174, in execute
  4. #    self.errorhandler(self, exc, value)
  5. #  File "/usr/lib/pymodules/python2.7/MySQLdb/connections.py", line 36, in defaulterrorhandler
  6. #    raise errorclass, errorvalue
  7. #_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL #server version for the right syntax to use near '' at line 1")
  8.  
  9.  
  10. #!/usr/bin/env python
  11. import csv
  12. import sys
  13. import MySQLdb
  14. conn = MySQLdb.connect(host="localhost",
  15.                   user="crushlb",
  16.                   passwd="adminpw111",
  17.                   db="crushlb")
  18.  
  19. x = conn.cursor()
  20.  
  21. f = open(sys.argv[1], 'rb')
  22. try:
  23.     reader = csv.reader(f)
  24.     offset = 27
  25.     for row_number, row in enumerate(reader):
  26.         username, password, path = row
  27.         x.execute("INSERT INTO `USERS` (`userid`, `username`, `password`, `server_group`) "
  28.                   "VALUES (%s, %s, %s, 'MainUsers')", (row_number+offset, username, password))
  29.         x.execute("INSERT INTO `VFS_PERMISSIONS` (`userid`, `path`, `privs`) "
  30.                   "VALUES (%s, %s, '(read)(write)(view)(delete)(resume)(share)(slideshow)(rename)(makedir)(deletedir)'", (row_number+offset, path))
  31. finally:
  32.     f.close()