Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import psycopg2
  2.  
  3. try:
  4. conn = psycopg2.connect("dbname=postgres user=postgres password=actuarial")
  5. print("database created successfully.")
  6. except psycopg2.OperationalError as ex:
  7. print("Connection failed: {0}".format(ex))
  8. cur = conn.cursor()
  9.  
  10. def create_client_table():
  11. cur.execute("CREATE TABLE ClientTable (ClientID SERIAL PRIMARY KEY, Name varchar);")
  12. print('student table created successfully')
  13.  
  14. create_client_table()
  15.  
  16. def client_add():
  17. name = input("Enter the names of the student:")
  18. cur.execute("INSERT INTO CleintTable VALUES (%s)", (name));
  19. cur.execute("SELECT * FROM StudentTable")
  20. rows = cur.fetchall()
  21. print(rows)
  22. client_add()
  23.  
  24. conn.close()
  25.  
  26. cur.execute("INSERT INTO CleintTable VALUES (%s)", (name));
  27.  
  28. TypeError: not all arguments converted during string formatting
  29.  
  30. cur.execute("INSERT INTO CleintTable VALUES (%s)", (name,));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement