0

Trying to learn some simple python/mariadb integration, and ran this script to add test values into a test database....

import mysql.connector as mariadb

mariadb_connection = mariadb.connect(user='root', password='password', database='testDatabase', host='localhost')
create_cursor = mariadb_connection.cursor()

create_cursor.execute("""INSERT INTO testtable (COLUMN1) VALUES ('HI')""")

So far so good, this is where the error comes up:

create_cursor.execute("""SELECT * from testtable""")
result = create_cursor.fetchall()
print(result)

Now when I run this code, it returns "[ ]", leading me to suspect this table is somehow empty- however, the insertion code threw no errors, and is perfectly in line with several online tutorials I found. Quite confused on this one (my apologies if this is a blatantly obvious problem- I am new to SQL).

0 Answers0