{"id":23024457,"url":"https://github.com/thipages/sqlitecli","last_synced_at":"2026-05-16T08:38:19.713Z","repository":{"id":57068907,"uuid":"282683580","full_name":"thipages/sqlitecli","owner":"thipages","description":"SQLite CLI PHP wrapper","archived":false,"fork":false,"pushed_at":"2021-08-09T23:17:30.000Z","size":56,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T08:44:18.723Z","etag":null,"topics":["cli","php","sqlite","wrapper"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thipages.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-26T15:57:55.000Z","updated_at":"2021-08-09T23:16:56.000Z","dependencies_parsed_at":"2022-08-24T14:54:13.760Z","dependency_job_id":null,"html_url":"https://github.com/thipages/sqlitecli","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fsqlitecli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fsqlitecli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fsqlitecli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thipages%2Fsqlitecli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thipages","download_url":"https://codeload.github.com/thipages/sqlitecli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246882872,"owners_count":20849330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","php","sqlite","wrapper"],"created_at":"2024-12-15T13:18:46.495Z","updated_at":"2026-05-16T08:38:14.691Z","avatar_url":"https://github.com/thipages.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlitecli\nSQLite CLI wrapper\n\n## Installation\n**composer** require thipages\\sqlitecli\n\n## Usage\n```php\n/* index.php */\n/* ********* */\n$cli=new SqliteCli('./database.db');\n$cli-\u003eexecute(\n    \"CREATE TABLE simple (id INTEGER PRIMARY KEY, name);\",\n    \"INSERT INTO simple (name) VALUES ('Paul'), ('Jack'),('Charlie');\",\n    '.mode csv',\n    '.headers on',\n    '.separator ,',\n    '.output data.csv',\n    'select id,name from simple limit 2;'\n);\n// OR\n$cli-\u003cexecute(\n    Orders::importCsv('simple','data.csv', ',', true),\n    Orders::exportCsv('data.csv', 'select id,name from simple limit 2;')\n);\n\n\n```\n```php\n// run it on server\nphp index.php\n```\n\n## Advanced usage\n- with functions only\n```php\n/* index.php */\n/* ********* */\n$cli=new SqliteCli('./database.db');\n$cli-\u003eexecute(\n    \"CREATE TABLE simple (id INTEGER PRIMARY KEY, name);\",\n    \"INSERT INTO simple (name) VALUES ('Paul'), ('Jack'),('Charlie');\",\n    \"SELECT name FROM simple WHERE id=1;\",\n    function($res) {\n        // Set 'Paul' to all records\n        return \"UPDATE simple SET name='$res'\";\n    }\n);\n```\n- with functions and registry\n```php\n/* index.php */\n/* ********* */\n$cli=new SqliteCli('./database.db');\n$cli-\u003eexecute(\n    \"CREATE TABLE simple (id INTEGER PRIMARY KEY, name);\",\n    \"INSERT INTO simple (name) VALUES ('Paul'), ('Jack'),('Charlie');\",\n    \"SELECT name FROM simple WHERE id=1;\",\n    Orders::registerAs('QUERY_ID=1'),\n    function($res, $registry) {\n        $newName=$registry-\u003eget(''QUERY_ID=1'');\n        return \"UPDATE simple SET name='$newName'\";\n    }\n);\n```\n\nSame result for both.\n\n## API\n\n**SqliteCli class**\n###### Constructor\n`SqliteCli($dbPath)`\n###### Methods\n`execute(...$orders):[boolean,array]` executes sqlite commands (list of [array of] commands). This method adds a final `.quit` command\n\n`getRegistry($key=null)` get the registry ouput value of `$key` or if null the registry as an associated array.\n\n**Orders class**\n###### Static methods\n`addPrimary($table,$primaryName):[boolean,array]` adds a primary field to an existing table (first position)\n\n`addField($table,$definition):[boolean,array]` adds a field to an existing table (first position)\n\n`importCsv($table, $csvPath, $separator=',', $headers='on'):array` returns an array of commands for csv import\n\n`exportCsv($csvPath, $separator=',', $headers='on'):array` returns an array of commands for csv export\n\n`mergeCsvList($table,$csvPaths, $delimiter=',')` merges csv Files into `$table`. Files need to have the same fields. `$delimiter` can be an array matching `$csvPaths`\n\n`getFieldList($table)` returns an array of the fields of `$table`\n\n`registerAs($key)` associates the previous output command to `$key` in the registry\n\n`unregister(...$keys)` associates the previous output command to `$key` in the registry","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthipages%2Fsqlitecli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthipages%2Fsqlitecli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthipages%2Fsqlitecli/lists"}