Advertisement
Guest User

Untitled

a guest
Feb 4th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #!/usr/bin/python
  2. # snippetbucket.com, author: tejas tank. Feb-2017
  3. # Backup table
  4.  
  5. import psycopg2
  6.  
  7. conn = psycopg2.connect(database="sch_mgmtss", user="", password="", host="", port="")
  8. print "Opened database successfully"
  9.  
  10. cur = conn.cursor()
  11. fo = open("j.csv", "wb")
  12. c = 1
  13.  
  14. while(c < 287315):
  15.  
  16. cur.execute("SELECT * FROM mail_message LIMIT 1 OFFSET %s"%c)
  17.  
  18. try:
  19. rows = cur.fetchone()
  20.  
  21. print rows
  22. fo.write("%s \n"%repr(rows))
  23.  
  24. except:
  25. print"c is not imported"
  26.  
  27.  
  28. fo.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement