Advertisement
Guest User

Untitled

a guest
Aug 26th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #! /usr/bin/python
  2.  
  3. import kivy
  4. kivy.require("1.10.0")
  5.  
  6. from kivy.app import App
  7. from kivy.uix.boxlayout import BoxLayout
  8. import psycopg2
  9.  
  10. class TestDB(BoxLayout):
  11.  
  12. def export_data(self):
  13. connection_str = "dbname = postgres user = postgres host = localhost password=psswd"
  14. conn = psycopg2.connect(connection_str)
  15. cur = conn.cursor()
  16.  
  17. cur.execute("INSERT INTO uniaxdb (patient_id,specimen_id) VALUES(
  18. 'test1','test2')")
  19. cur.close()
  20.  
  21. class TestDBApp(App):
  22. def build(self):
  23. return TestDB()
  24.  
  25. if __name__ == '__main__':
  26. TestDBApp().run()
  27.  
  28. <TestDB>:
  29. orientation: 'vertical'
  30.  
  31. BoxLayout:
  32.  
  33. Button:
  34. text: "export to DB"
  35. on_release: root.export_data()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement