This repository has been archived on 2025-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
desktop_app/app/core/database.py
2025-09-06 05:10:09 +03:00

22 lines
544 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sqlite3
import os
DB_PATH = "messenger.db"
def get_connection():
return sqlite3.connect(DB_PATH)
def init_db():
if not os.path.exists(DB_PATH):
conn = get_connection()
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS chats (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL
)
''')
cursor.execute('INSERT INTO chats (title) VALUES (?)', ("Чат с Alice",))
conn.commit()
conn.close()