[sqlite] Windows binaries compiled with ICU

2016-02-28 Thread Petr Lázňovský
Looking for %subj%, unable to find 'sqlite3.exe' with ICU extensions. Does it 
exist at all? If yes, couls anyone post link?

thanks L.




[sqlite] UNIQUE constraint failed: ip_addr.pid

2015-09-14 Thread Petr Lázňovský
Thay track all of us and "optimalise" search results. My list of links could 
differ from yours.

I have googled key phrase '"UNIQUE constraint failed:" sqlite primary key' and 
similar, but not read whole received documents, perform only brief look on it. 
This is best practice by my experience, english is not my first language and 
reading whole long documents is painfullness for me.

Apology to boring experts with dumb question.

L.

> Hi Petr,

> if you Google for "database table primary key" the first few results lead to 
> quite good explanations.
> Also, the english wikipedia's article "Unique key" explains primary keys.

> HTH
> Martin


> Am 14.09.2015 22:25 schrieb Petr L?z?ovsk? :

>> I had googled to verify such idea before, but have no luck.

>> Thanks, L.

>> > Hello Petr,

>> > defining the column pid as INTEGER PRIMARY KEY you added an implicit 
>> > contraint; a primary key means that only one record with a given value 
>> > of pid can exist in the table.
>> > See https://www.sqlite.org/lang_createtable.html#rowid

>> > Martin

>> > Am 14.09.2015 um 21:04 schrieb Petr L?z?ovsk?:
>> >> Have following table:

>> >> CREATE TABLE ip_addr
>> >> (
>> >> /*! Person identificator (PID) %%a */ pid INTEGER PRIMARY KEY NOT NULL,
>> >> /*! IP address %%b */ ip_addr VARCHAR (16) NOT NULL,
>> >> /*! Status: 0 - Allowed, Unassigned to specific customer (blocked) */
>> >> /*! Status: 1 - Allowed, Asigned to concrete customer */
>> >> /*! Status: 2 - Disallowed, Assigned to blocked user */
>> >> /*! Status: 3 - Disallowed, Assigned to history user */
>> >> /*! Status of IP address %%c */ ip_status INTEGER NOT NULL,
>> >> /*! Type: 1 - Private */
>> >> /*! Type: 2 - Public */
>> >> /*! Type: 3 - IPv6 */
>> >> /*! Type of IP address %%d */ ip_type INTEGER NOT NULL,
>> >> /*! Date of blocking %%e */ blocked_at INTEGER,
>> >> /*! Blocking note %%f */ blocking_note VARCHAR
>> >> );
>> >> )

>> >> If inserting row containing PID already exist in table, sqlite generate 
>> >> %subj% error. But there is not such constraint in database definition. 
>> >> Did I miss something?

>> >> L.

>> >> ___
>> >> sqlite-users mailing list
>> >> sqlite-users at mailinglists.sqlite.org
>> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

>> > ___
>> > sqlite-users mailing list
>> > sqlite-users at mailinglists.sqlite.org
>> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users




[sqlite] UNIQUE constraint failed: ip_addr.pid

2015-09-14 Thread Petr Lázňovský
I had googled to verify such idea before, but have no luck.

Thanks, L.


> Hello Petr,

> defining the column pid as INTEGER PRIMARY KEY you added an implicit 
> contraint; a primary key means that only one record with a given value 
> of pid can exist in the table.
> See https://www.sqlite.org/lang_createtable.html#rowid

> Martin

> Am 14.09.2015 um 21:04 schrieb Petr L?z?ovsk?:
>> Have following table:

>> CREATE TABLE ip_addr
>> (
>> /*! Person identificator (PID) %%a */ pid INTEGER PRIMARY KEY NOT NULL,
>> /*! IP address %%b */ ip_addr VARCHAR (16) NOT NULL,
>> /*! Status: 0 - Allowed, Unassigned to specific customer (blocked) */
>> /*! Status: 1 - Allowed, Asigned to concrete customer */
>> /*! Status: 2 - Disallowed, Assigned to blocked user */
>> /*! Status: 3 - Disallowed, Assigned to history user */
>> /*! Status of IP address %%c */ ip_status INTEGER NOT NULL,
>> /*! Type: 1 - Private */
>> /*! Type: 2 - Public */
>> /*! Type: 3 - IPv6 */
>> /*! Type of IP address %%d */ ip_type INTEGER NOT NULL,
>> /*! Date of blocking %%e */ blocked_at INTEGER,
>> /*! Blocking note %%f */ blocking_note VARCHAR
>> );
>> )


>> If inserting row containing PID already exist in table, sqlite generate 
>> %subj% error. But there is not such constraint in database definition. Did I 
>> miss something?

>> L.


>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users




[sqlite] UNIQUE constraint failed: ip_addr.pid

2015-09-14 Thread Petr Lázňovský
Have following table:

CREATE TABLE ip_addr 
(
/*! Person identificator (PID) %%a */ pid INTEGER PRIMARY KEY NOT NULL,
/*! IP address %%b */ ip_addr VARCHAR (16) NOT NULL,
/*! Status: 0 - Allowed, Unassigned to specific customer (blocked) */
/*! Status: 1 - Allowed, Asigned to concrete customer */
/*! Status: 2 - Disallowed, Assigned to blocked user */
/*! Status: 3 - Disallowed, Assigned to history user */
/*! Status of IP address %%c */ ip_status INTEGER NOT NULL,
/*! Type: 1 - Private */
/*! Type: 2 - Public */
/*! Type: 3 - IPv6 */
/*! Type of IP address %%d */ ip_type INTEGER NOT NULL,
/*! Date of blocking %%e */ blocked_at INTEGER,
/*! Blocking note %%f */ blocking_note VARCHAR
);
)


If inserting row containing PID already exist in table, sqlite generate %subj% 
error. But there is not such constraint in database definition. Did I miss 
something?

L. 




[sqlite] BEGINNER - Transactions in shell script

2015-09-13 Thread Petr Lázňovský
I would like thanks to all contributors of this interesting debate, for their 
effort.

L. 


> As with Rob, this is my final say as well.

> On Fri, Sep 11, 2015 at 1:38 PM, Petr L?z?ovsk? wrote:

>> 1. Security through obscurity is your first mistake. There is no such thing.
>  
>  Interesting It does not exist, but it have article on wikipedia. Sounds 
> like UFO or Yetti...




> "Security through Obscurity" in layman terms is that you provide no 
> additional valid information to whomever is accessing your system.  If you're 
> URL provides CGI in its path, it points (Doesn't necessarily MEAN) more at 
> that it is a Linux box than a Windows box.  That doesn't mean it isn't, just 
> that it is more likely to.  Looking at HTTP headers, you can find out what OS 
> your script is running on, what version of PHP, ASP, .NET, whatever.  Black 
> Hats typically keep a very long list of found security holes on every single 
> version of whatever script processor you're using.  Obscurity means you're 
> just muddying the waters, or hiding facts, or acting like an outright liar.  
> It doesn't mean your system becomes locked down and people aren't going to be 
> interested ESPECIALLY if you're found to be on a fat pipe to the net.  
> Because Security through Obscurity is becoming more mainstream, I'm sure 
> these Black Hats don't even look at that and have techniques to just get what 
> they need done.

>  
>  
 >> 2. Assuming that nobody is writing CGI scripts on Windows Servers is your 
 >> next mistake. A lot of systems still do this, a lot of old systems still 
 >> use this technique and some new ones, The attack vector is not necessarily 
 >> through your CGI script itself but through the Windows Web server. Unless 
 >> you have patched and patched and patched your web server, you will be 
 >> attacked.
>  
>  Of course I keep my web server software up-to-date, why do you think I do 
> not did it? I am talking here about my scripts, not about the server SW. But 
> the server SW is relatively rare too...




> "Scripts" and the underlying script processors are what do the processing.  
> OS updates are one thing, but the script processing engine is another, and so 
> are the scripts you write.  If any one of those three links in the chain are 
> broken, then buh-bye security.  The script processor talks to the OS to get 
> things done, such as allocate memory, set aside a portion of drive space, 
> execute other code, etc.  If you don't sanitize your inputs 100% of the time 
> properly, you're subject to losing a LOT of information or having your 
> machine taken over, or as Rob mentions, resources sold (A thought I hadn't 
> even  thought about).  The 'execute other code' should scare the bejezus out 
> of you.  If your system is allowed to run other code (Say, for example, [ ls 
> -ltr /etc ] to get a directory list), if you don't sanitize your code, 
> someone can (Not might, CAN if you don't sanitize) change that to [ ls -ltr 
> /etc ; rm -rf /etc ] and if Apache has access to write anything there, you 
> have a new install of an OS to do.


> The company I work for sells software for the web that runs off both IIS and 
> Apache under Linux.  Both are scrutinized for security even though the main 
> portion of the software is behind a paywall (Need credentials to get into the 
> heart and main functions of the system) and all communications are via HTTPS. 
>  All HTTPS does is ensure that no one else knows what you're saying on the 
> socket, essentially.  It doesn't mean that the system isn't hackable.  If we 
> didn't ensure that the login field on the login page wasn't sanitized, then 
> we're pretty much bending over.

>  
>  
 >> 3. You assume that nobody is interested in your machine. Wrong. A lot of 
 >> people are very interested as they can add your hacked server to their 
 >> bonnet and sell your resources on. Your machine does not have to be 
 >> publicised at all. As an example, I have a private server which I use. It 
 >> has no DNS entry (a common way to search for machines), so is only 
 >> accessible through an IP address which has never been published. It only 
 >> has a single ssh port open and port 80 for a private web server running 
 >> some software there rest of the machine is locked down as best I can. The 
 >> lock down took me a day to do. It is not trivial. My last weekly report 
 >> showed over 200,000 attempts to break into the machine via ssh, http, and 
 >> various CGI exploits. Thats 200,000 robot attempts, the most prevalent was 
 >> an ssh attempt from a single machine which accounted for 72,000 goes. A 
 >> public web server I have has over 1M hacking attempts per week. This is for 
 >> a low usage machine.
>  
>  Script kiddies starting codes writen to attack widely spreaded systems, 
> otherwise it will be not much fun. Some of this codes could be specialized to 
> intrude minor systems, but I have doubts there are number of working scripts 
> to successfuly in

[sqlite] BEGINNER - Transactions in shell script

2015-09-11 Thread Petr Lázňovský
> 1. Security through obscurity is your first mistake. There is no such thing. 

Interesting It does not exist, but it have article on wikipedia. Sounds 
like UFO or Yetti...   

> 2. Assuming that nobody is writing CGI scripts on Windows Servers is your 
> next mistake. A lot of systems still do this, a lot of old systems still use 
> this technique and some new ones, The attack vector is not necessarily 
> through your CGI script itself but through the Windows Web server. Unless you 
> have patched and patched and patched your web server, you will be attacked. 

Of course I keep my web server software up-to-date, why do you think I do not 
did it? I am talking here about my scripts, not about the server SW. But the 
server SW is relatively rare too... 

> 3. You assume that nobody is interested in your machine. Wrong. A lot of 
> people are very interested as they can add your hacked server to their bonnet 
> and sell your resources on. Your machine does not have to be publicised at 
> all. As an example, I have a private server which I use. It has no DNS entry 
> (a common way to search for machines), so is only accessible through an IP 
> address which has never been published. It only has a single ssh port open 
> and port 80 for a private web server running some software there rest of the 
> machine is locked down as best I can. The lock down took me a day to do. It 
> is not trivial. My last weekly report showed over 200,000 attempts to break 
> into the machine via ssh, http, and various CGI exploits. Thats 200,000 robot 
> attempts, the most prevalent was an ssh attempt from a single machine which 
> accounted for 72,000 goes. A public web server I have has over 1M hacking 
> attempts per week. This is for a low usage machine. 

Script kiddies starting codes writen to attack widely spreaded systems, 
otherwise it will be not much fun. Some of this codes could be specialized to 
intrude minor systems, but I have doubts there are number of working scripts to 
successfuly intrude systems with rare occurance.

Real hackers, those who are experienced in writing WORKING code targeted to 
intrude one specific rare system, need a REAL reason to did such job. My system 
does not offer such reason

> I give your machine less than 24 hours once it is live on the internet if you 
> put it on without taking security seriously. You need to get the OS patched 
> up, the ports closed down, the web server patched up and correctly 
> configured. Out of the box the security on a Windows server (depending on the 
> version) is poor. You need to learn what you need to do (and there are loads 
> of guides on the internet) otherwise your server will be owned by somebody 
> else very quickly. 

As I already wrote, not using IIS. OS is protected by manualy configured 
firewall. By concept Security through obscurity using this one 
http://wipfw.sourceforge.net/ Intruding script perform OS detection first, but 
do  not expect BSD firewall on Windows... Simple as it. Did you understand STO 
concept now?

L.

BTW: There is smile next this "trust me" this obviously means: Do not took it 
too seriously

> To be blunt you have misunderstood computer security, Saying ?trust me? 
> doesn?t work. 

> Best of luck,

> Rob

>> On 11 Sep 2015, at 13:42, Petr L?z?ovsk?  wrote:

>> There is a major difference: You are talking about SSH and Linux, this 
>> combination running on hundred milions of network devices accross whole 
>> internet. Thus develop intruding scripts does make sense. But I am using 
>> Windows shell scripts as CGI, which is EXTREMELY rare. Who will study this 
>> technique to intrude my (or very few another) systems? No one trust me 
>> ;-)

>> L.

>> BTW: If someone did it anyway, I will give him medal and start experinces 
>> sharing to him 

>>> You'd be surprised by what is out there trying to get into your system.

>>> I had port 22 open on my home router to go to a Linux machine so I could 
>>> SSH into my home network from anywhere in the world, even though I rarely 
>>> ever leave the 519 area code.  One day I went to look at my messages log 
>>> file and noted numerous brute force attempts to get into my machine.  
>>> Fortunately, the machine is setup so that you can't SSH in as root, and the 
>>> single login name that has any kind of access root capable access is 
>>> intentionally camel cased to thwart name dictionary attacks.  The attacks 
>>> were automated at their end, obviously, but if you have a machine exposed, 
>>> someone is going to have software that will do anything and everything to 
>>> gain access through whatever weakest link you have.


>>> I'm on a residential cable line, with an IP that changes periodically, 
>>> however, I'm still subject to attacks.  SSH is a common thing, and what you 
>>> have written may not be interesting to the hacker space as a whole, 
>>> however, there is that one idiot out there that WILL take the time to break 
>>> into your system for jolli

[sqlite] BEGINNER - Transactions in shell script

2015-09-11 Thread Petr Lázňovský
There is a major difference: You are talking about SSH and Linux, this 
combination running on hundred milions of network devices accross whole 
internet. Thus develop intruding scripts does make sense. But I am using 
Windows shell scripts as CGI, which is EXTREMELY rare. Who will study this 
technique to intrude my (or very few another) systems? No one trust me ;-)

L.

BTW: If someone did it anyway, I will give him medal and start experinces 
sharing to him 

> You'd be surprised by what is out there trying to get into your system.

> I had port 22 open on my home router to go to a Linux machine so I could SSH 
> into my home network from anywhere in the world, even though I rarely ever 
> leave the 519 area code.  One day I went to look at my messages log file and 
> noted numerous brute force attempts to get into my machine.  Fortunately, the 
> machine is setup so that you can't SSH in as root, and the single login name 
> that has any kind of access root capable access is intentionally camel cased 
> to thwart name dictionary attacks.  The attacks were automated at their end, 
> obviously, but if you have a machine exposed, someone is going to have 
> software that will do anything and everything to gain access through whatever 
> weakest link you have.


> I'm on a residential cable line, with an IP that changes periodically, 
> however, I'm still subject to attacks.  SSH is a common thing, and what you 
> have written may not be interesting to the hacker space as a whole, however, 
> there is that one idiot out there that WILL take the time to break into your 
> system for jollies.





> On Fri, Sep 11, 2015 at 6:12 AM, Petr L?z?ovsk?  wrote:


>  Never heard about this. Thinked about this a bit, but have no idea how it 
> could menace my CGI application. But as far I am a beginner, expecting it 
> could be a menace but rely on Security by obscurity. Some time a go, when I 
> start writing CGI powered by windows shell scripts, I have serched (almost 
> whole) internet for some examples or informations, but I found nothing. 
> That means I am lonely with this technique ;-) No hacker will study such 
> weird technique to intrude only one system on whole internet ;-)
>  
>  L.





[sqlite] BEGINNER - Transactions in shell script

2015-09-11 Thread Petr Lázňovský

> SQL commands do not need to be on multiple lines (they only need a
> semicolon after each command).
> But dot commands do.

Good to know

> Have you tried the following?
> (ECHO .bail on
> ECHO %multiple commands%) | sqlite3.exe %dbname%

This could be solution, thanks

> But, much more importantly (particularly since you included BEGINNER in big
> letters in your subject line): are you protecting your DB against SQL
> injection attacks? I imagine this would be rather hard to do from a script,
> unless you have already sanitized data coming in.

Never heard about this. Thinked about this a bit, but have no idea how it could 
menace my CGI application. But as far I am a beginner, expecting it could be a 
menace but rely on Security by obscurity. Some time a go, when I start writing 
CGI powered by windows shell scripts, I have serched (almost whole) internet 
for some examples or informations, but I found nothing. That means I am 
lonely with this technique ;-) No hacker will study such weird technique to 
intrude only one system on whole internet ;-) 

L.

> On 7 September 2015 at 18:53, Simon Slavin  wrote:


>> On 7 Sep 2015, at 8:00am, Petr L?z?ovsk?  wrote:

>> > Uhgh Spent lot of time to made whole scripts bundle to use no
>> tempfiles (avoiding I/Os), and not this ;-)
>> > OK, few more questions:
>> >
>> > Does sqlite3 expect exactly one statement per one line on input?
>> > Or put it into command line? sqlite3.exe %db% "%multiline_statement%"
>> (have seriuos doubts about this solution)
>> > Or this? echo "%multiline_statement%"|sqlite3.exe %db%

>> I can tell you if this works on the Macintosh version but this may not
>> necessarily mean it works on the version for your operating system.

>> If not, create a text file with the commands in then feed it the text
>> file.  The command could look like

>> sqlite3 %db% < theCommands.txt

>> I think the structure you used above ...

>> Unix/Linux:
>> cat theCommands.txt | sqlite3.exe %db%
>> Windows:
>> type theCommands.txt | sqlite3.exe %db%

>> will also work.

>> You may find it useful to figure out a way of generating a filename which
>> will never be repeated.  When I try to do this I usually end up with
>> something which relates to the current time.

>> Simon.
>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users




[sqlite] BEGINNER - Transactions in shell script

2015-09-07 Thread Petr Lázňovský
Uhgh Spent lot of time to made whole scripts bundle to use no tempfiles 
(avoiding I/Os), and not this ;-)
OK, few more questions:

Does sqlite3 expect exactly one statement per one line on input?
Or put it into command line? sqlite3.exe %db% "%multiline_statement%" (have 
seriuos doubts about this solution)
Or this? echo "%multiline_statement%"|sqlite3.exe %db%

Any other ways, if invented ways are lunatics?

L.

> On 6 Sep 2015, at 7:46pm, Petr L?z?ovsk?  wrote:

>> Thanks to all answers. Are principles of such script OK, or I miss something?

> Sorry you cannot script sqlite.exe like that.  Each time you run it is a 
> separate session.  your BEGIN has no useful effect.

> Simon.




[sqlite] BEGINNER - Transactions in shell script

2015-09-06 Thread Petr Lázňovský
Thanks to all answers. Are principles of such script OK, or I miss something?


set "_error="
sqlite3.exe %db% BEGIN;
for /f "tokens=2,3 delims=," %%a in (data.csv) do (
sqlite3 %db% "INSERT INTO payments(id,amount) VALUES 
('%%a','%%b')";
if errorlevel 1 set "_error=y"
)
if not defined _error (
sqlite3.exe %db% COMMIT;
) else (
sqlite3.exe %db% ROLLBACK;
call stop_perform_another_scheduled_writings.cmd
call notify_admin_payment_writing_failed.cmd
)


L.




[sqlite] BEGINNER - Transactions in shell script

2015-09-05 Thread Petr Lázňovský
Have some shell scripts working with sqlite. Receiving incoming payments from 
bank via HTTP API and pushing it into database. This script will start 
periodically, every single hour. 

Want to prevent situation only few payments are written and script failed for 
some reason. Have read about sqlite transactions and understood so I should 
start every writing sequence with BEGIN; statement, than made all inserts and 
than COMMIT; statement. Is this all how it is working? Should I do something 
more to prevent such unwanted situation?

thanks, L. 




[sqlite] Result code differs running commands from script file and from console

2015-03-15 Thread Petr Lázňovský
As far as I understood you comment (english is not my first language), 
executing script could not provided specified resultcode because many fails can 
occur and exitcode is only one? 

But multiple fails can occurs on long cmdline too. What happens on this case? 
My logic says the internal sqlite command parser stop on first error founded, 
set-up exitcode, print error message and terminate. After correction this 
error, than start displaying second error, until all errors are corrected 
(ideal).

L.

> On Sat, Mar 14, 2015 at 7:33 AM, Petr L?z?ovsk? wrote:

> Just discovered the resulcodes differ if perform:

>  
>  sqlite3.exe %db% < script.sql

>  the %errorlevel% is 1
>  

>  but by

>  
>  sqlite3.exe %db% "UPDATE table SET '='";

>  the errorlevel is 19 (correct as by 
> "https://www.sqlite.org/c3ref/c_abort.html";)
>  --

>  both command produce same (correct) erromessage:

>  Error: near line 1: UNIQUE constraint failed: table.



>  Why I got different exitcodes? Is is possible to get proper exitcode if 
> command loaded from script file too?



> According to your logic ...which error code do you believe should be returned 
> if a plurality of the SQLite statements in your piped script file were to 
> cause some variety of different  error events?



> --
>--
>   --
>  --???--
> K e V i N

>  




[sqlite] Result code differs running commands from script file and from console

2015-03-14 Thread Petr Lázňovský
Just discovered the resulcodes differ if perform:


sqlite3.exe %db% < script.sql

the %errorlevel% is 1


but by 


sqlite3.exe %db% "UPDATE table SET '='";

the errorlevel is 19 (correct as by "https://www.sqlite.org/c3ref/c_abort.html";)
--

both command produce same (correct) erromessage:

Error: near line 1: UNIQUE constraint failed: table.



Why I got different exitcodes? Is is possible to get proper exitcode if command 
loaded from script file too?

L.




Re: [sqlite] insert image into db - windows batch

2012-01-19 Thread Petr Lázňovský


> On Thu, Jan 19, 2012 at 1:49 AM, Kevin Benson wrote:

>>  On Wed, Jan 18, 2012 at 8:16 PM, Simon Slavin wrote:


>>> On 18 Jan 2012, at 11:13pm, Petr Lázňovský wrote:

>>> > Look like script for different platform, but "od" and "tr" are
>>> available also for Win so I will try...

>>> I would probably look for a Windows version of 'hexdump'.

>>> Simon.
>>>  ___



>> ...or maybe | xxd.exe | which seems to have a parameter to also "reverse"
>> the operation:

>> http://code.google.com/p/unix-cmd-win32/downloads/detail?name=xxd.exe

>> --
>>--
>>   --
>>  --ô¿ô--
>> K e V i N




> Another possibility is the Swiss File Knife utility which has a command for
> conversion and back:

> http://www.portablefreeware.com/forums/viewtopic.php?p=28023&sid=fb6c6562cfe85a8ac7ecd8dd0b954cf9#p28023

I know this, but this tool is too big to packing inside of batch, xxd (35kb) is 
ten times smaller compare to sfk (370kb).



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert image into db - windows batch

2012-01-18 Thread Petr Lázňovský
Look like script for different platform, but "od" and "tr" are available also 
for Win so I will try...

> On Wed, 18 Jan 2012 13:30:49 +0100, Petr Láz?ovský 
> wrote:


 have windows batch working with sqlite, may I insert image into database 
 and than read this images from?

>>> Convert your image into a BLOB and store it as a BLOB.  BLOBs are just runs 
>>> of bytes -- you can store anything you want as a BLOB.

>>What you mean by "Convert image into a BLOB" is there some kind of SW to do 
>>this? Does SQLite offer some way to do this? Sorry for dumb question, but I 
>>googling about this some time with no luck..

>>I found only http://www.vive.net/products/image2db.htm but this is GUI tool, 
>>not suitable for scripting..


> Try this one liner demo (wrapped by mail) to insert file contents into a
> database table:

> d=test.db3 ; echo "CREATE TABLE Files (name TEXT PRIMARY KEY,contents
> BLOB);" | sqlite3 $d ; for f in yourfiles* ; do echo "INSERT INTO Files
> (name,contents) VALUES ('$f',X'$(od -v -A n -t x1 $f|tr -d '\r\n\t
> ')');" | sqlite3 $d ; done

> I'll leave the extraction from database to files as an exercise for the
> reader.



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert image into db - windows batch

2012-01-18 Thread Petr Lázňovský


> Sorry, 'windows batch' doesn't mean anything to me.

http://en.wikipedia.org/wiki/Batch_file

but wikipedia is reasonlessly turned off today



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert image into db - windows batch

2012-01-18 Thread Petr Lázňovský
Because of packing. The script should be distributable as one .cmd file, the 
database engine and database itself will be embeded inside od script. Dealing 
with embeded files in the shell script is not easy thus I want to minimize its 
number.

L. 

> On Jan 18, 2012, at 12:00 PM, Petr Lázňovský wrote:

>> have windows batch working with sqlite, may I insert image into database and 
>> than read this images from?

> As pointed out, you might want to use the 'blob' type to store binary data.

> That said, why bother storing these images inside the database itself? Any 
> benefit in doing so? 

> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert image into db - windows batch

2012-01-18 Thread Petr Lázňovský
> On 18 Jan 2012, at 12:30pm, Petr Lázňovský wrote:

>>>> have windows batch working with sqlite, may I insert image into database 
>>>> and than read this images from?

>>> Convert your image into a BLOB and store it as a BLOB.  BLOBs are just runs 
>>> of bytes -- you can store anything you want as a BLOB.

>> What you mean by "Convert image into a BLOB" is there some kind of SW to do 
>> this? Does SQLite offer some way to do this? Sorry for dumb question, but I 
>> googling about this some time with no luck..

> If you don't already know how to use your programming language to store 
> integers and strings in a SQLite database, then learn that first.  Once you 
> have software which can do that, read on:

> An image (assuming you mean a file like a .jpeg or .png file) is just a long 
> run of bytes.  You can store a long run of bytes in a SQLite database as data 
> of type 'BLOB'.  This isn't a string, or a number, or a date, it's just a 
> long run of bytes which is stored exactly as supplied with no interpretation.

> So in your software, open the image file and read the contents of the file 
> into memory.  Then use the SQLite library routine to create a new row, and 
> bind that piece of memory to a BLOB.  When you want to retrieve that data, 
> read the BLOB back out of the database.  Then if you want to make an image 
> file of it you can do that.  If you want to display the image on the screen 
> without making a file of it, you can do that instead if your programming 
> language gives you way to do it.

> The exact routines to use depends on the language your software is written 
> in: C, Python, PHP, whatever.  That's all down to your personal programming 
> choice.  But all the commonly-used interfaces to SQLite have the ability to 
> handle BLOBs.

Simon,

did you read the subject of my mail? I am use sqlite from Win batch (shell) 
scripting by commands like:

sqlite3.exe main.db "Insert into Table1 values('','','');"

or

sqlite3.exe main.db "select * from Table1 where Column='';"

I am currently not a programmer (means Do not know any REAL language, only 
partialy Win shell) and this is my first deal with databases at all. So please 
be patient with me ;-)
 
In Win shell AFAIK everything is a text, there are no data types. I spent much 
time with google, but seems nobody uses this combination (Win shell + sqlite) 
so there are very few informations on web :-/

L.







___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert image into db - windows batch

2012-01-18 Thread Petr Lázňovský

>> have windows batch working with sqlite, may I insert image into database and 
>> than read this images from?

> Convert your image into a BLOB and store it as a BLOB.  BLOBs are just runs 
> of bytes -- you can store anything you want as a BLOB.

What you mean by "Convert image into a BLOB" is there some kind of SW to do 
this? Does SQLite offer some way to do this? Sorry for dumb question, but I 
googling about this some time with no luck..

I found only http://www.vive.net/products/image2db.htm but this is GUI tool, 
not suitable for scripting..

L.

 


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] insert image into db - windows batch

2012-01-18 Thread Petr Lázňovský
have windows batch working with sqlite, may I insert image into database and 
than read this images from?

L.


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users