INNER CODE UNIT · Python

setup_database

buzzsubash/algo_trading_strategies_india · broker-utilities/mtm_square_off_zerodha/zerodha_ltp_subscriber.py:123

    def setup_database(self):
        """Setup unified SQLite database with WAL mode"""
        try:
            self.conn = sqlite3.connect('zerodha_trading.db', check_same_thread=False, timeout=30)
            self.cursor = self.conn.cursor()

            # Enable WAL mode for better concurrent access (creates .wal and .shm files)
            self.cursor.execute('PRAGMA journal_mode=WAL')
            self.cursor.execute('PRAGMA synchronous=NORMAL')
            self.cursor.execute('PRAGMA cache_size=10000')

            # Create unified LTP data table
            self.cursor.execute('''
                CREATE TABLE IF NOT EXISTS ltp_data (
                    instrument_token INTEGER PRIMARY KEY,
                    tradingsymbol TEXT,
                    exchange TEXT,
                    last_price REAL NOT NULL,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…