Re: [sqlite] .importing file into a BLOB
>Something like (one line, wrapped by email): > >echo "INSERT INTO t1 (id,pic) VALUES (1,X'$(od -A n -t x1 >picture.gif | tr -d '\r\n\t\ ')')" | sqlite3 mydb > >(The od utility may be smarter than that, optimization left >to the OP) Looks good, you know better than I do. Just checked: od and tr are available under MinGW. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] .importing file into a BLOB
On Thu, 10 Dec 2009 04:57:58 +0100, Jean-Christophe Deschampswrote: > is to >use a command-line tool or combination thereof that will open your >binary file, read each byte in turn and output its hex value in plain >ASCII characters, until end of file. Something like (one line, wrapped by email): echo "INSERT INTO t1 (id,pic) VALUES (1,X'$(od -A n -t x1 picture.gif | tr -d '\r\n\t\ ')')" | sqlite3 mydb (The od utility may be smarter than that, optimization left to the OP) >That (possibly long) chain of >text can be stored as a single BLOB without any problem using for >instance an SQL file fed to sqlite3.exe. -- ( Kees Nuyt ) c[_] ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] .importing file into a BLOB
Ted, >Is it the command-line program misinterpreting the CR/LFs? Unfortunately, any command-line tool will interpret control characters at their face value when they are fed directly. With no ad hoc program doing it for you, the solution, as I've discussed at length before and even if it is far from optimal, is to use a command-line tool or combination thereof that will open your binary file, read each byte in turn and output its hex value in plain ASCII characters, until end of file. That (possibly long) chain of text can be stored as a single BLOB without any problem using for instance an SQL file fed to sqlite3.exe. Another much simpler possibility is to use one of the good SQLite managers available and use it to load the data/file in the cell where it belongs. It all depends if you need to do that in a very small number of instances or if you have to perform such loading routinely. >I'm reluctantly on a Windows system. Don't feel like a rebel, despite its problems you can have some work done. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] .importing file into a BLOB
.import imports data from a file in CSV format. In a CSV file a newline indicates a new record. If you want all your data to be in one record have all your data on one line. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] .importing file into a BLOB
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wed, 09 Dec 2009 11:48:31 -0800 Roger Binnswrote: > http://catb.org/~esr/faqs/smart-questions.html What wasn't clear? I apologize for any murkiness. My understanding is that a BLOB takes any piece of data and stores it away intact. Is it the command-line program misinterpreting the CR/LFs? I'm reluctantly on a Windows system. I have no C compiler. PHP might be an option, but I can't get PDO to work. Any direction is appreciated. Ted -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.12 (MingW32) iQGcBAEBAgAGBQJLIGBFAAoJEAWk0Z459zwzd0gL/2vAgDbGJ0H2NBnv+ajEsRhj PaaevYyTRQOg+8ndZhtzQ1Fw6X579e3gi1k+zrvfDxmPIVpXk22y1Vf2olNAAmpR EuhJI7oxghMuKYGCj1nX8MnjdyDGn3az/7kYBkhFVJhEya7rLKzc+7BHkr+zt3x9 H3JoMMxoWEhPtwu75nbjAtUbOLHsKZWv3UYFUrqr5WoqBXbUNwl9Ld7zprOob2cD H71EyiR7ulItrdSF8kdob1OTptNxSiek1uFgaidimNYhTsh+vEBCoH5hFzVc8tSQ uoHZ21c+4tNgRVgRfMcfsBU4a/Ryzrl8V3+qibMuna+UAPoEN5Xcztb/mHWXsyj6 P96JpV86I786rZOsx4etGYlCGmFnpWDzbo563nP9gxs8WF8dwXnk8udpHua+2u9E CUXyODmMhGQVY7p+b7ApwcCu4qon43kLG63XHpajnaHaO97Y8z35iFu96zFLXMbD fU3LyVPCw8Go2l/p4s75vhV8smkuIOhmDt1mjv9LGg== =W7xS -END PGP SIGNATURE- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users