diff options
Diffstat (limited to 'doc/note')
-rw-r--r-- | doc/note/sqlite/execSqlFileThroughPhp.txt | 17 | ||||
-rw-r--r-- | doc/note/sqlite/sqlite.txt | 15 | ||||
-rw-r--r-- | doc/note/windoof/excel-csv-problems.txt | 14 |
3 files changed, 46 insertions, 0 deletions
diff --git a/doc/note/sqlite/execSqlFileThroughPhp.txt b/doc/note/sqlite/execSqlFileThroughPhp.txt new file mode 100644 index 0000000..3bb4126 --- /dev/null +++ b/doc/note/sqlite/execSqlFileThroughPhp.txt @@ -0,0 +1,17 @@ +<?php +$srcSqlFile = "path/to/query.sql"; +$dstDbFile = "path/to/sqlite.db"; +$stmts = file_get_contents($srcSqlFile); +$stmts = explode(';', $stmts); +$db = new SQLite3($dstDbFile); +$db->enableExceptions(true); +foreach( $stmts AS $stmtStr ){ + $stmtStr = trim($stmtStr); + if( !$stmtStr ) continue; + $st = $db->prepare($stmtStr .';'); + $st->execute(); + //$id = $db->lastInsertRowID(); + //if( $id ){ echo "lastInsertRowID() -> $id\n"; } + $st->close(); +} +$db->close(); diff --git a/doc/note/sqlite/sqlite.txt b/doc/note/sqlite/sqlite.txt index 8a79368..3805e07 100644 --- a/doc/note/sqlite/sqlite.txt +++ b/doc/note/sqlite/sqlite.txt @@ -25,3 +25,18 @@ csv Example (no headrow): sqlite3 foo.db -bail -cmd '.mode csv' -cmd '.separator ;' -cmd '.import foo.csv FooTable' + +## Drop Column + + ALTER TABLE table DROP COLUMN column; + + +## Add Column + + ALTER TABLE table ADD COLUMN column NOT NULL DEFAULT 'gugus'; + + +## Refs + +[drop column TODO vote](https://stackoverflow.com/a/66399224/4415884) + diff --git a/doc/note/windoof/excel-csv-problems.txt b/doc/note/windoof/excel-csv-problems.txt new file mode 100644 index 0000000..1560e3a --- /dev/null +++ b/doc/note/windoof/excel-csv-problems.txt @@ -0,0 +1,14 @@ + +## Generate a CSV so excel won't corrupt data on opening + +Make a formula of each cell. So Wrap value in double quotes and +prepend by equal sign. This way, it will be TEXT for excel. + +Another option is to prepend a tab for each value. + + +## Refs + +[excel csv gen (TODO vote)](https://superuser.com/a/527894/1123359) + + |