Answer the question
In order to leave comments, you need to log in
How to write different types of data with Python to SQL table?
Hey!
I have a list with different types of values:
[561906993, 52262538, '2003-12-12 21:52:09', 'Fall', '0.0000320', '0.01929000', '0.00147425']
And a way to add new information to the table
cursor = connection.cursor()
print(addinfo)
# Выполнение SQL-запроса для вставки данных в таблицу
insert_query = f""" INSERT INTO postgreetest_db (t1, t2, t3, t4,t5,t6,t7) VALUES (561906993, 52262538, '2003-12-12 21:52:09', 'Fall', '0.0000320', '0.01929000', '0.00147425')"""
resultat = [561906993, 52262538, '2003-12-12 21:52:09', 'Fall', '0.0000320', '0.01929000', '0.00147425']
cursor = connection.cursor()
print(addinfo)
# Выполнение SQL-запроса для вставки данных в таблицу
insert_query = f""" INSERT INTO postgreetest_db (t1, t2, t3, t4,t5,t6,t7) VALUES ({resultat })"""
cursor.execute(insert_query)
connection.commit()
cursor.execute("SELECT * from postgreetest_db")
record = cursor.fetchall()
print("Результат", record)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question