Make db name configurable
This commit is contained in:
@ -15,10 +15,11 @@ from slack_sdk.errors import SlackApiError
|
|||||||
|
|
||||||
|
|
||||||
INDICATOR = "$$"
|
INDICATOR = "$$"
|
||||||
|
DB_NAME = os.environ.get("DB_NAME", "kowalski.db")
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
# Initialize SQLite database
|
# Initialize SQLite database
|
||||||
conn = sqlite3.connect("message_counts.db", check_same_thread=False)
|
conn = sqlite3.connect(DB_NAME, check_same_thread=False)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
# Create table if it doesn't exist
|
# Create table if it doesn't exist
|
||||||
@ -27,8 +28,7 @@ cursor.execute('''
|
|||||||
user_id TEXT PRIMARY KEY,
|
user_id TEXT PRIMARY KEY,
|
||||||
message_count INTEGER
|
message_count INTEGER
|
||||||
)
|
)
|
||||||
''')
|
''') cursor.execute('''
|
||||||
cursor.execute('''
|
|
||||||
CREATE TABLE IF NOT EXISTS messages (
|
CREATE TABLE IF NOT EXISTS messages (
|
||||||
sender_user_id TEXT PRIMARY KEY,
|
sender_user_id TEXT PRIMARY KEY,
|
||||||
receiver_user_id TEXT,
|
receiver_user_id TEXT,
|
||||||
|
|||||||
Reference in New Issue
Block a user