Package: airtable-to-sqlite
Airtable to SQliteTable of ContentsInstallationUsageDatabase formatAlternativesFuture developmentLicenseInstallationpip install airtable-to-sqliteUsageThe tool is primarily intended to be used through the command line. Once installed, you can use it like this:airtable-to-sqliteapp123456789This will fetch the base with the IDapp123456789and save it to a file calledBaseName.dbin your current directory.AuthenticationFor the tool to work you need to authenticate with Airtable API using a personal access token. To generate a token visityour Airtable account.There are two ways to use the token. You can set it as an environment variable (calledAIRTABLE_PERSONAL_ACCESS_TOKEN), and the tool will pick it up:exportAIRTABLE_PERSONAL_ACCESS_TOKEN=patABCDE123456789
airtable-to-sqliteapp123456789Or you can pass it to the tool directly:airtable-to-sqlite--personal-access-tokenpatABCDE123456789app123456789Download more than one baseYou can add more Base IDs to download more than one Base.airtable-to-sqliteapp123456789app567891234These will be saved toBase1Name.dbandBase2Name.dbrespectively.Customise the output fileTo customise the name of the file where the database will be saved, just pass the--outputparameter. So for example:airtable-to-sqlite--output"output.db"app123456789Will save the file tooutput.db. If you include{}in the filename it will be replaced with the name of the base. So for example:airtable-to-sqlite--output"db/{}/output.db"app123456789Will result in a file saved todb/BaseName/output.db.The string{}must be included if more than one Base is requested, omitting it will produce an error.Use IDs instead of namesBy default, the tool will use the names of tables, fields and bases. You can use the--prefer-idsflag to tell the tool to use the IDs instead.If this flag is used it will mean the filenames use the Base ID (egapp123456789.dbinstead ofBaseName.db), the table names will use IDs instead of names, and columns within the tables will be named using IDs.This may be helpful if your table or field names contain characters that can't be used in sqlite. You can use the_meta_tableand_meta_fieldtables (see below) to find the names of the tables and columnsDatabase formatEach table within the Airtable Base gets in own table within the database. Each of these tables always contains two default fields, and then the rest of the data from the table. The additional fields are:_id: The airtable ID for the record. This is set as the primary key_createdTime: The date and time the record was created.All fields are stored in the database, with the exception of fields with the typemultipleRecordLinks, which are instead stored in a linking table.Where possible, the tool will attempt to assign an appropriate column type to each field. Note that constraints on these fields are not enforced by sqlite by default, so the database may contain invalid data.Storage for linked recordsWhere a field has the typemultipleRecordLinks, i.e. where it is a record that links to other records in another table, a linking table is created. The name of this table is{table_name}_{field_id}, and it always contains two columns, with foreign key constraints to their tables:recordId: the record in the original tableotherRecordId: the record in the linked tableNote that these fields contain many-to-many relationships, so values in both fields may appear more than once.Meta tablesIn addition to the main data tables from the Base, the tool creates tables holding metadata about the original Base and the export process. These tables are:_meta_tableA record for each table in the Base. Fields are:id: (str) Airtable Table IDname: (str) Table nameprimaryFieldId: (str) ID of the primary field_meta_fieldA record for each field in each table in the Base. Fields are (only the first 4 fields are mandatory):id: (str) Airtable Field IDname: (str) Field Nametype: (str) Type of fieldtableId: (str) Airtable Table IDoptions: (json) Any remaining options not covered by other variableslinkedTableId: (str) For fields of typemultipleRecordLinks, the other table looked upisReversed: (bool)prefersSingleRecordLink: (bool)inverseLinkFieldId: (str)isValid: (bool)recordLinkFieldId: (str)icon: (str)color: (str)referencedFieldIds: (str)result: (str)precision: (str)symbol: (str)_meta_field_choiceWhere a field has choices (e.g. where it is a single or multiple select field), this table contains the options. Fields are:id: (str) Choice IDname: (str) Choice Namecolor: (str)fieldId: (str) Airtable Field ID_meta_viewA record for each view in the Base. Fields are:id: (str) Airtable View IDname: (str) View nametableId: (str) Airtable Table IDThis table doesn't contain enough information to reconstruct the view._meta_settingsEach record contains a key value pair with a piece of metadata, for example the original Base ID and Base Name. Fields are:key: (str)value: (str)Alternativesairtable-exportby @simonwFuture developmentPotential future developments include:Viewer/editor for exported filesGreater coverage of available fieldsexport to Excel (could be a separate tool)Contributions are very welcome.Licenseairtable-to-sqliteis distributed under the terms of theMITlicense.