N
N
nnikolyaa2020-08-06 11:04:05
Python
nnikolyaa, 2020-08-06 11:04:05

sqlite3 error?

An error occurs on startup:

_partially initialized module 'sqlite3' has no attribute 'connect' (most likely due to a circular import)


The code itself:

import sqlite3 as sq
    
with sq.connect('users.db') as con:
    cur = con.cursor()
    cur.execute("""CREATE TABLE  IF NOT EXISTS users(
    chat_id INTEGER,
    user_id INTEGER,	
    first_name TEXT,
    second_name TEXT,
    nick TEXT,
    money INTEGER DEFAULT 0
    )""")

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
SKEPTIC, 2020-08-06
@nnikolyaa

Is this all code?
Your piece of code runs and works for me.
What is the name of your Python script? The case is not sqlite3?
The directory with the script should not contain files named sqlite3.py

A
Alexander, 2020-08-06
@shabelski89

It seems you have created a module named sqlite3? It is he who is imported instead of the desired one, rename the file.

S
soremix, 2020-08-06
@SoreMix

Somewhere nearby in the folder there is sqlite3.py, which interferes
. Although there may not be enough rights to create.
What shows

import sqlite3 as sq
print(dir(sq))
print(sq.version)

?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question