Aug-01-2021, 11:59 AM
I pass the database name from form to the cdb.py it is successful, but the mariadb query "CREATE DATABASE ?" cannot get the value i think so, this is cdb.py
when i run the cdb.py directly from command line this is the error:
# Get Cursor
cur = conn.cursor()
# creating database
cur.execute("CREATE DATABASE ?", (val,))
cur.execute("SHOW DATABASES")
databaseList = cur.fetchall()
for database in databaseList:
print(database)
conn.close() when i run the cdb.py directly from command line this is the error:
<!-- The above is a description of an error in a Python program, formatted
for a Web browser because the 'cgitb' module was enabled. In case you
are not reading this in a Web browser, here is the original traceback:
Traceback (most recent call last):
File "/srv/http/cgi-bin/./cdb.py", line 31, in <module>
cur.execute("CREATE DATABASE ?", (val,))
mariadb.ProgrammingError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1
-->This is the error printing in web browser when i run from the web browser: /srv/http/cgi-bin/cdb.py in <module>
29 cur = conn.cursor()
30 # creating database
=> 31 cur.execute("CREATE DATABASE ?", (val,))
32
33 cur.execute("SHOW DATABASES")
cur = <mariadb.connection.cursor object>, cur.execute = <built-in method execute of mariadb.connection.cursor object>, val = 'mydb'
ProgrammingError: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1
args = ("You have an error in your SQL syntax; check the ...on for the right syntax to use near '?' at line 1",)
errmsg = "You have an error in your SQL syntax; check the ...on for the right syntax to use near '?' at line 1"
errno = 1064
msg = "You have an error in your SQL syntax; check the ...on for the right syntax to use near '?' at line 1"
sqlstate = '42000'
with_traceback = <built-in method with_traceback of ProgrammingError object>
