This repository has been archived on 2026-07-21. You can view files and clone it, but cannot push or open issues or pull requests.
Files
edo/database/init_db.py
2026-07-14 01:16:33 +03:00

69 lines
1.2 KiB
Python
Raw Permalink 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.

from datetime import datetime
def init_db(conn):
cursor = conn.cursor()
# Контрагенты
cursor.execute("""
CREATE TABLE IF NOT EXISTS contractors (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE,
active INTEGER DEFAULT 1
)
""")
# Документы из 1С
cursor.execute("""
CREATE TABLE IF NOT EXISTS documents_1c (
id INTEGER PRIMARY KEY AUTOINCREMENT,
contractor_id INTEGER,
doc_type TEXT,
doc_date TEXT,
doc_number TEXT,
amount REAL,
state TEXT,
comment TEXT,
created_at TEXT,
updated_at TEXT,
FOREIGN KEY(contractor_id)
REFERENCES contractors(id)
)
""")
# Документы из СБИС
cursor.execute("""
CREATE TABLE IF NOT EXISTS documents_sbis (
id INTEGER PRIMARY KEY AUTOINCREMENT,
raw_text TEXT,
doc_date TEXT,
doc_number TEXT,
contractor TEXT,
doc_type TEXT,
amount REAL,
description TEXT,
state TEXT,
responsible TEXT,
comment TEXT,
created_at TEXT,
updated_at TEXT
)
""")
conn.commit()