Issues (53)

weekorm/db.py (11 issues)

1
import sqlite3
0 ignored issues
show
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
SETTINGS = {
4
    'db_name': '',
5
    'connection': '',
6
}
7
8
9
def set_db_name(db_name):
0 ignored issues
show
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
10
    SETTINGS['db_name'] = db_name
11
    SETTINGS['connection'] = sqlite3.connect(db_name)
12
13
14
def get_cursor():
0 ignored issues
show
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
15
    if not SETTINGS.get('connection'):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable SETTINGS does not seem to be defined.
Loading history...
16
        SETTINGS['connection'] = sqlite3.connect(SETTINGS['db_name'])
17
    cursor = SETTINGS['connection'].cursor()
0 ignored issues
show
The Instance of str does not seem to have a member named cursor.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
18
    return cursor
19
20
21
def db_commit():
0 ignored issues
show
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
22
    SETTINGS['connection'].commit()
0 ignored issues
show
The Instance of str does not seem to have a member named commit.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
23
24
25
def execute_sql(cursor, sql):
0 ignored issues
show
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
26
    try:
27
        cursor.execute(sql)
28
    except Exception as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
29
        print('error')
30
        print(sql)
31
        raise e
32
33
34
class DataBase:
0 ignored issues
show
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
The variable __class__ seems to be unused.
Loading history...
35
36
    def __init__(self, name):
37
        self.db_name = name
38
        self.connection = sqlite3.connect(name)
39
        self.cursor = self.connection.cursor()
40
        self._save_settings()
41
42
    def _save_settings(self):
43
        SETTINGS['connection'] = self.connection
44
        SETTINGS['db_name'] = self.db_name
45
46
    def __del__(self):
47
        self.connection.close()
48