Include SQLite3 schemas #52
                
     Open
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This is a simple addition to detect sqlite3 databases and include the schema of tables, views and indexes.
The sqlite database is detected if the file is binary and has the correct magic number header. (https://www.sqlite.org/fileformat.html). Only detects SQLite3 as that is what Python3 uses.
The schema is only include if the option --extract-sqlite is provided.
❯ python3 -m files_to_prompt ../example/test.db --extract-sqlite ../example/test.db --- -- SQLite3 Database Schema -- Tables CREATE TABLE knowledge_records ( id TEXT PRIMARY KEY, source_file TEXT, source_type TEXT, type TEXT, domain TEXT, author TEXT, content JSON, created_at TEXT, version TEXT, embedding BLOB, used_in_consensus BOOLEAN DEFAULT FALSE ); CREATE TABLE test_table ( id INTEGER PRIMARY KEY, -- Primary key (INTEGER) col_integer INTEGER, -- INTEGER col_int INT, -- Alias for INTEGER col_smallint SMALLINT, -- Small integer col_tinyint TINYINT, -- Tiny integer col_bigint BIGINT, -- Big integer col_real REAL, -- Floating point number col_double DOUBLE, -- DOUBLE (treated as REAL) col_double_precision DOUBLE PRECISION, -- Another DOUBLE variant col_float FLOAT, -- FLOAT (also REAL) col_numeric NUMERIC, -- NUMERIC type col_decimal DECIMAL(10,2), -- DECIMAL with precision/scale col_boolean BOOLEAN, -- BOOLEAN (stored as INTEGER 0/1) col_date DATE, -- DATE (stored as TEXT) col_datetime DATETIME, -- DATETIME (stored as TEXT) col_text TEXT, -- TEXT col_varchar VARCHAR(100), -- VARCHAR with a length limit col_blob BLOB -- Binary data ); -- Views CREATE VIEW test_view AS SELECT id, col_text, col_date, col_boolean FROM test_table; -- Indexes CREATE INDEX idx_col_date ON test_table(col_date); CREATE INDEX idx_col_integer ON test_table(col_integer); CREATE INDEX idx_col_text ON test_table(col_text); ---