Skip to content

Commit

Permalink
Fix database name being ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Jul 21, 2017
1 parent 10fad87 commit 4c690ac
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions chatterbot/storage/sql_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SQLStorageAdapter(StorageAdapter):
can be especified to choose database driver (database parameter will be igored).
:type database_uri: str
:keyword read_only: False by default, makes all operations read only, has priority over all DB operations
:keyword read_only: False by default, makes all operations read only, has priority over all DB operations
so, create, update, delete will NOT be executed
:type read_only: bool
Expand All @@ -104,20 +104,17 @@ def __init__(self, **kwargs):
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

self.database_name = self.kwargs.get("database")

if self.database_name:

# Create a sqlite file if a database name is provided
self.database_uri = self.kwargs.get(
"database_uri", "sqlite:///" + self.database_name + ".db"
)

# The default uses sqlite in-memory database
# The default uses a sqlite in-memory database
self.database_uri = self.kwargs.get(
"database_uri", "sqlite://"
)

database_name = self.kwargs.get("database")

# Create a sqlite file if a database name is provided
if database_name:
self.database_uri = "sqlite:///" + database_name + ".db"

self.engine = create_engine(self.database_uri)

self.read_only = self.kwargs.get(
Expand Down

0 comments on commit 4c690ac

Please sign in to comment.