a.py 556 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. # -*- coding: UTF-8 -*-
  3. import os
  4. import pymysql.cursors
  5. import sys
  6. print ("222222", sys.argv[1])
  7. # 连接数据库
  8. connect = pymysql.Connect(
  9. host='192.168.1.50',
  10. port=3326,
  11. user='root',
  12. passwd='root',
  13. db='zp30o1_db',
  14. charset='utf8'
  15. )
  16. cursor = connect.cursor()
  17. sql = "select * from user"
  18. cursor.execute(sql)
  19. for row in cursor.fetchall():
  20. print(row[2])
  21. print('共查找出', cursor.rowcount, '条数据')
  22. # main
  23. def main():
  24. print ("hello world!")
  25. # start
  26. if __name__ == "__main__":
  27. main()