R
R
Roki99992020-05-12 11:18:14
Python
Roki9999, 2020-05-12 11:18:14

Sqlite Python.Error what to do?

import sqlite3
conn = sqlite3.connect("mydatabase.db")
cursor = conn.cursor()
CREATE TABLE login (
id INT (11) NOT NULL,
user_name TEXT (256) NOT NULL);

ERROR:
File "db.py", line 4
    CREATE TABLE login (
           ^
SyntaxError: invalid syntax

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2020-05-12
@Roki9999

Sorry, but this is already some kind of p ... c. You would at least look through the simplest reference book chtoli.

import sqlite3
conn = sqlite3.connect("mydatabase.db")
cursor = conn.cursor()
cursor.execute('CREATE TABLE login (id INT (11) NOT NULL,user_name TEXT (256) NOT NULL)')

S
Sergey Gornostaev, 2020-05-12
@sergey-gornostaev

Learn more Python. Your current level is not enough to write a program.

N
nzarchii60, 2020-05-12
@nzarchii60

This error can be thrown if the database has ALREADY been created.
And you are trying to create the same database with the same name.
In this case, you need to connect to the database,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question