i have this basic sql file:
CREATE TABLE `app_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(200) DEFAULT NULL,
`password` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
and want to execute it via python:
connect_str = "dbname='dbname' user='user' host='192.168.1.101' password='password'"
conn = psycopg2.connect(connect_str)
cursor = conn.cursor()
fd = open('file.sql', 'r')
sqlFile = fd.read()
fd.close()
sqlCommands = sqlFile.split(';')
for command in sqlCommands:
print(command)
if command.strip() != '':
cursor.execute(command)
When i execute this via "python3 app.py", it connects, but i just get:
psycopg2.ProgrammingError: syntax error at or near "`"
LINE 1: CREATE TABLE `app_users` (
But i have no idea why.. anybody could help me with this issue?
thanks and greetings
create tablescript to the PostgreSQL"