Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- try:
- conn = psycopg2.connect("dbname=postgres user=postgres password=actuarial")
- print("database created successfully.")
- except psycopg2.OperationalError as ex:
- print("Connection failed: {0}".format(ex))
- cur = conn.cursor()
- def create_client_table():
- cur.execute("CREATE TABLE ClientTable (ClientID SERIAL PRIMARY KEY, Name varchar);")
- print('student table created successfully')
- create_client_table()
- def client_add():
- name = input("Enter the names of the student:")
- cur.execute("INSERT INTO CleintTable VALUES (%s)", (name));
- cur.execute("SELECT * FROM StudentTable")
- rows = cur.fetchall()
- print(rows)
- client_add()
- conn.close()
- cur.execute("INSERT INTO CleintTable VALUES (%s)", (name));
- TypeError: not all arguments converted during string formatting
- cur.execute("INSERT INTO CleintTable VALUES (%s)", (name,));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement