imantha
imantha

Reputation: 3828

Error: Module 'sqlite3' has no connect member

I have written a few python code lines. But I keep on getting the following error: Module 'sqlite3' has no 'connect' member pylint(no-member)[6,8]. Any ideas what might be causing this.

import sqlite3
import os
os.chdir('D:/SQL/Databases')

conn = sqlite3.connect('GVP - Eruptions Trial 1.2.db')

Upvotes: 0

Views: 4811

Answers (2)

Eric Camellini
Eric Camellini

Reputation: 41

PyLint does not load C extensions by default, as a security measure to prevent arbitrary code execution.

To whitelist just the sqlite3 C extension, you can include in your project a .pylintrc file with the following content:

[MASTER]

# Whitelisting sqlite3 C extension
extension-pkg-allow-list=_sqlite3

You can verify that it gets read correctly by running pylint --generate-rcfile in your terminal to print the current config loaded by pylint. You should see that the option you added is there:

enter image description here

This solved it for me:

enter image description here

Upvotes: 2

paxdiablo
paxdiablo

Reputation: 881563

You can safely ignore these PyLint warnings.

As a security measure, PyLint does not import untrusted C extensions (we may trust SqLite but PyLint defines "trusted" as being in the standard library). See here for details (including how to whitelist your extensions if you want to remove the warnings).

The reason it does not import it is because that would allow an attacker to run arbitrary code. If it had a way of creating the AST (abstract syntax tree) without importing (i.e., by just examining the file), it would be a lot safer.

It should, however, run just fine.

Upvotes: 1

Related Questions