![]() ![]() Remove the default value for this column. Remove the primary key from this table, turning it into a rowid table. Pass -pk multiple times if you want to create a compound primary key. pk column-nameĬhange the primary key column for this table. not-null-false column-nameįor a column that is currently set as NOT NULL, remove the NOT NULL. Use this multiple times to specify a new order for your columns. drop column-nameĭrop the specified column. Valid types are integer, text, float, blob. The options are as follows: -type column-name new-typeĬhange the type of the specified column. $ sqlite-utils transform mydb.db mytable \Įvery option for this table (with the exception of -pk-none) can be specified multiple times. The duplicate command duplicates a table - creating a new table with the same schema and a copy of all of the rows: See Explicitly creating a table in the Python library documentation for details of how this option works. You can also pass -transform to transform the existing table to match the new schema. ![]() You can choose to silently ignore this error with -ignore, or you can replace the existing table with a new, empty table using -replace. If a table with the same name already exists, you will get an error. $ sqlite-utils tables books.db -schema -t $ sqlite-utils create-table books.db books \ $ sqlite-utils create-table books.db authors \ You can insert data piped from standard input like this: ![]() The filename without the extension - for this would be file.txt suffix The integer size of the file in bytes stem The creation time is an ISO timestamp size The modification time as an ISO timestamp, e.g. The creation time as an integer rather than a float mtime_iso The modification time as an integer rather than a float ctime_int The creation time of the file, as floating point seconds since the Unix epoch mtime_int The modification time of the file, as floating point seconds since the Unix epoch ctime The text file contents, which will be stored as TEXT mtime The binary file contents, which will be stored as a BLOB content_text The permission bits of the file, as an integer - you may want to convert this to octal content The fully resolved path to the image, e.g. The path to the file relative to the root folder, e.g. The full list of column definitions you can use is as follows: name Pass -alter to cause any missing columns to be added to the table. You can pass -replace or -upsert to indicate what should happen if you try to insert a file with an existing primary key. c path -c md5 -c last_modified:mtime -pk=path $ sqlite-utils insert-files gifs.db images *.gif \ To see indexes for specific tables, list those after the database: Ny_times_us_counties idx_ny_times_us_counties_state 0 2 state 0 BINARY 1 Ny_times_us_counties idx_ny_times_us_counties_county 0 1 county 0 BINARY 1 Ny_times_us_counties idx_ny_times_us_counties_fips 0 3 fips 0 BINARY 1 Ny_times_us_counties idx_ny_times_us_counties_date 0 0 date 1 BINARY 1 Johns_hopkins_csse_daily_reports idx_johns_hopkins_csse_daily_reports_day 0 0 day 0 BINARY 1 Johns_hopkins_csse_daily_reports idx_johns_hopkins_csse_daily_reports_province_or_state 0 2 province_or_state 0 BINARY 1 Johns_hopkins_csse_daily_reports idx_johns_hopkins_csse_daily_reports_country_or_region 0 1 country_or_region 0 BINARY 1 Johns_hopkins_csse_daily_reports idx_johns_hopkins_csse_daily_reports_combined_key 0 12 combined_key 0 BINARY 1 Table index_name seqno cid name desc coll key This is the default subcommand, so the following two examples work the same way: ![]() The sqlite-utils query command lets you run queries directly against a SQLite database file. Setting defaults and not null constraints Using a convert() function to execute initializationĬonverting a column into multiple columnsĪdding columns automatically on insert/update Inserting unstructured data with -lines and -textĪpplying conversions while inserting data Joining in-memory data against existing databases using -attachĪlternative delimiters and quote characters Running queries directly against CSV or JSON Querying data directly using an in-memory database Returning raw data, such as binary content It can also be run using python -m sqlite_utils. Once installed the tool should be available as sqlite-utils. The sqlite-utils command-line tool can be used to manipulate SQLite databases in a number of different ways. Toggle table of contents sidebar sqlite-utils command-line tool # ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |