Re: [sqlite] open db cx to fork(2)d children

2010-07-09 Thread Nicolas Williams
On Fri, Jul 09, 2010 at 02:38:08PM -0700, Roger Binns wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 07/09/2010 02:31 PM, Nicolas Williams wrote: > > The trick to making that go fast is to use pthread_atfork() to get the > > new PID on the child side of fork() and store the PID

Re: [sqlite] open db cx to fork(2)d children

2010-07-09 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/09/2010 02:31 PM, Nicolas Williams wrote: > The trick to making that go fast is to use pthread_atfork() to get the > new PID on the child side of fork() and store the PID in a global > variable so that you don't need to call getpid(). That

Re: [sqlite] open db cx to fork(2)d children

2010-07-09 Thread Nicolas Williams
On Fri, Jul 09, 2010 at 02:22:37PM -0700, Roger Binns wrote: > On 07/09/2010 01:52 PM, Eric Smith wrote: > > What do you mean, "immediately"? As I said, my child comes to life, > > does some work without touching (its copy of) existing SQLite strucures, > > and then calls exit(2). > > I'll bet

Re: [sqlite] open db cx to fork(2)d children

2010-07-09 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/09/2010 01:52 PM, Eric Smith wrote: > What do you mean, "immediately"? As I said, my child comes to life, > does some work without touching (its copy of) existing SQLite strucures, > and then calls exit(2). I'll bet you are actually getting

Re: [sqlite] open db cx to fork(2)d children

2010-07-09 Thread Nicolas Williams
On Fri, Jul 09, 2010 at 04:52:35PM -0400, Eric Smith wrote: > > > I strongly recommend that you always make the child side of fork(2) > > either exit(2) or exec(2) immediately. > > Sorry Nico, I never saw this response -- I appreciate it! > > What do you mean, "immediately"? Good question.

Re: [sqlite] open db cx to fork(2)d children

2010-07-09 Thread Eric Smith
> I strongly recommend that you always make the child side of fork(2) > either exit(2) or exec(2) immediately. Sorry Nico, I never saw this response -- I appreciate it! What do you mean, "immediately"? As I said, my child comes to life, does some work without touching (its copy of) existing

Re: [sqlite] concat 2 const chars ?

2010-07-09 Thread Martin Engelschalk
Hi, i think you are asking a C question, and not an sql question. Is your example C code? If this is the case, you should read up on C basics. Feel free to contact me directly (also in German) Martin Am 09.07.2010 21:06, schrieb rollerueckwaerts: > Hello, > I try to get an sql query string from

Re: [sqlite] concat 2 const chars ?

2010-07-09 Thread Sam Carleton
I really don't mean to be a jerk, but this does seem to be really off topic for this mailing list. Isn't the concatination of two string a general C/C++ question rather then a sqlite question? Don't you think you might be better off asking this question on a C/C++ mailing list or forum, maybe

Re: [sqlite] How to concat column

2010-07-09 Thread P Kishor
On Fri, Jul 9, 2010 at 2:35 PM, Peng Yu wrote: > On Sun, Jul 4, 2010 at 7:15 PM, P Kishor wrote: >> On Sun, Jul 4, 2010 at 6:15 PM, Peng Yu wrote: >>> Hi, >>> >>> I only find row-wise concatenation by not column-wise. >>> >>> For

Re: [sqlite] sqlite query with c++ variable

2010-07-09 Thread Eric Smith
smengl90 wrote: > Hi, I want to compose a query that will use a c++ variable. For example I > have: > > int i= 5; > char * query = "SELECT * from userInfo WHERE count<'i'". > > The syntax does not work. How do I do that? I think your primary problem is lack of experience in C++. I strongly

Re: [sqlite] sqlite query with c++ variable

2010-07-09 Thread Sam Carleton
On Fri, Jul 9, 2010 at 2:48 PM, smengl90 wrote: > > Hi, I want to compose a query that will use a c++ variable. For example I > have: > > int i= 5; > char * query = "SELECT * from userInfo WHERE count<'i'". > > The syntax does not work. How do I do that?

Re: [sqlite] EXTERNAL: concat 2 const chars ?

2010-07-09 Thread Black, Michael (IS)
You must be thinking of Java or such -- C doesn't do concatenation that way. There is a strcat() function but that's an ugly way to do it. Here's how I'd do it: int language=6; int nbytes; char sql[65535]; // big sql buffer to store whatever we need nbytes=snprintf(sql,sizeof(sql),"SELECT

Re: [sqlite] concat 2 const chars ?

2010-07-09 Thread Adam DeVita
and don't use strcpy here is why https://buildsecurityin.us-cert.gov/bsi-rules/home/g1/848-BSI.html On Fri, Jul 9, 2010 at 3:06 PM, rollerueckwaerts wrote: > > Hello, > I try to get an sql query string from 2 const chars. > > const char *language; > language = "'6'"; >

Re: [sqlite] concat 2 const chars ?

2010-07-09 Thread Adam DeVita
>From the point of view of a C question, make your array of characters large enough to hold the characters you want (and terminating null) before copying them in. >From the point of view of an SQL: if you want to change the comparison constant in a where clause, look up bind parameters. read

Re: [sqlite] Null character problem

2010-07-09 Thread Kavita Raghunathan
I'm apologise for the reminder, but I think I have become a victim of "thread takeover". Would someone please kindly answer my questions ? Kavita On 7/9/10 11:41 AM, "Kavita Raghunathan" wrote: > Thanks. Sounds like I have to use BLOBs which is not what I'm

Re: [sqlite] How to concat column

2010-07-09 Thread Peng Yu
On Sun, Jul 4, 2010 at 7:15 PM, P Kishor wrote: > On Sun, Jul 4, 2010 at 6:15 PM, Peng Yu wrote: >> Hi, >> >> I only find row-wise concatenation by not column-wise. >> >> For example, I have table >> >> x1 y1 >> x1 y2 >> x2 y3 >> x4 y4 >> >> I want to

Re: [sqlite] Corrupted sqlite journal

2010-07-09 Thread Jim Wilcoxson
On Fri, Jul 9, 2010 at 3:21 PM, Jim Wilcoxson wrote: > On Fri, Jul 9, 2010 at 10:38 AM, Ke Tao wrote: > >> >> HI All , >> >> I have sqlite db name "wdb" and "wdb-journal" file was created by power >> failure something , when I do any db operation sqlite

Re: [sqlite] Corrupted sqlite journal

2010-07-09 Thread Jim Wilcoxson
On Fri, Jul 9, 2010 at 10:38 AM, Ke Tao wrote: > > HI All , > > I have sqlite db name "wdb" and "wdb-journal" file was created by power > failure something , when I do any db operation sqlite always prompt "disk > I/O error" , but when I delete the "wdb-journal" ,there is no

[sqlite] WAL: no longer able to use read-only databases?

2010-07-09 Thread Matthew L. Creech
In testing the latest SQLite snapshot with WAL enabled, it seems that there's no way to use a database in a read-only location. For example, let's say I've created a database as root, then closed it (cleanly): $ ls -l /flash/alarms.db* -rw-r--r--1 root root 36864 Jan 1 00:14

[sqlite] concat 2 const chars ?

2010-07-09 Thread rollerueckwaerts
Hello, I try to get an sql query string from 2 const chars. const char *language; language = "'6'"; const char *sql2 = "SELECT key,name,text FROM uebersetzungen WHERE sprach_id = "; const char *sql = strcpy(sql2,language); // or const char *sql = "SELECT key,name,text FROM

[sqlite] sqlite query with c++ variable

2010-07-09 Thread smengl90
Hi, I want to compose a query that will use a c++ variable. For example I have: int i= 5; char * query = "SELECT * from userInfo WHERE count<'i'". The syntax does not work. How do I do that? Thanks -- View this message in context:

Re: [sqlite] Null character problem

2010-07-09 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/09/2010 10:54 AM, Eric Smith wrote: > My question came purely from a mild curiosity. I was wondering about > the behavior of sqlite call sqlite3_bind_text when it is passed a range > of BYTES that includes nulls. bind_text and bind_blob use

Re: [sqlite] Null character problem

2010-07-09 Thread Virgilio Alexandre Fornazin
>> My question came purely from a mild curiosity. I was wondering about >> the behavior of sqlite call sqlite3_bind_text when it is passed a range >> of BYTES that includes nulls. See this snipper for documentation: "The third argument is the value to bind to the parameter. In those routines

[sqlite] sqlite query with c

2010-07-09 Thread smengl90
-- View this message in context: http://old.nabble.com/sqlite-query-with-c-tp29120975p29120975.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org

[sqlite] More WAL questions and concerns.

2010-07-09 Thread A. H. Ongun
A few questions that are my application specific that is an embedded application. I have two databases, the first one is a fixed size configuration database where all writes are UPDATES, and the database does not get that many writes. Does this mean that because of WAL the database itself

Re: [sqlite] Null character problem

2010-07-09 Thread Eric Smith
Simo Slavin wrote: > (according to your earlier post) I'm not OP. I'm Eric. OP was someone else. In this context, I don't care about blobs or about the right way of doing anything. > Read the documentation for memset(). I know quite well how memset works. I know character!=byte.

Re: [sqlite] Null character problem

2010-07-09 Thread H. Phil Duby
On Fri, Jul 9, 2010 at 10:48 AM, Eric Smith wrote: > Will sqlite3_bind_text work properly if the string contains (internal) > nulls?  What if I did something like: > > char zText[100]; > memset(zText, 0, sizeof(zText)); > sqlite3_bind_text(stmt, idx, zText, sizeof(zText),

Re: [sqlite] Null character problem

2010-07-09 Thread Simon Slavin
On 9 Jul 2010, at 5:48pm, Eric Smith wrote: > Simon Slavin wrote: > >> BLOBs can handle any sequences of bytes without problems, >> including nulls, ETX, and sequences which be illegal if they were used to >> express Unicode characters. You can put anything you like in a BLOB. > > I

Re: [sqlite] Null character problem

2010-07-09 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/09/2010 09:30 AM, Jay A. Kreibich wrote: > They can't be stored as text values without some type of encoding > (like base64), but they can be stored as BLOBs. Nulls can be stored in text values. Behind the scenes SQLite treats strings and

Re: [sqlite] Null character problem

2010-07-09 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/09/2010 09:24 AM, Kavita Raghunathan wrote: > 1. Is this an issue for storing in database ? If strcpy is used anywhere, > it would be a problem SQLite quite happily stores/retrieves null bytes in strings. It is part of my test suite. If

Re: [sqlite] Null character problem

2010-07-09 Thread Eric Smith
Simon Slavin wrote: > BLOBs can handle any sequences of bytes without problems, > including nulls, ETX, and sequences which be illegal if they were used to > express Unicode characters. You can put anything you like in a BLOB. I assume, due to the manifest typing semantics of the library,

Re: [sqlite] Null character problem

2010-07-09 Thread Simon Slavin
On 9 Jul 2010, at 5:29pm, Eric Smith wrote: > I have no specific knowledge on whether sqlite handles null characters > within the variables' values--but if I were a bettin man, I'd bet that > it handles them quite cleanly. You win. BLOBs can handle any sequences of bytes without problems,

Re: [sqlite] Null character problem

2010-07-09 Thread Jay A. Kreibich
On Fri, Jul 09, 2010 at 11:24:19AM -0500, Kavita Raghunathan scratched on the wall: > Hello, > I?m storing encrypted passwords in the sqlite database. The encryption > algorithm generates ?null? character, and therefore the password > strings can have nulls in them. > > 1. Is this an issue for

Re: [sqlite] Null character problem

2010-07-09 Thread Eric Smith
Kavita Raghunathan wrote: > sprintf(SqlStr, "INSERT INTO %s (AttrName, AttrEnum, AttrType, > AttrValue, ReadWrite, Entity_id) VALUES('%s', %d, %d, '%s', %d, > %d);", tbl_name, db[i]->attr_name, db[i]->attr_num, db[i]->attr_type, > db[i]->attr_value, db[i]->attr_src, entity_id); Don't do

[sqlite] Null character problem

2010-07-09 Thread Kavita Raghunathan
Hello, I’m storing encrypted passwords in the sqlite database. The encryption algorithm generates “null” character, and therefore the password strings can have nulls in them. 1. Is this an issue for storing in database ? If strcpy is used anywhere, it would be a problem 2. I’m using

[sqlite] WAL: Wrong error "database disk image is malformed"

2010-07-09 Thread Alexey Pechnikov
I have long running test in WAL mode (inserting millions of records in autocommit mode). In other connection by sqlite3 shell I see these errors: sqlite> select (select count(*) from role_exist)/1000/1000; 12 sqlite> select (select count(*) from role_exist)/1000/1000; Error: file is encrypted or

[sqlite] Corrupted sqlite journal

2010-07-09 Thread Ke Tao
HI All , I have sqlite db name "wdb" and "wdb-journal" file was created by power failure something , when I do any db operation sqlite always prompt "disk I/O error" , but when I delete the "wdb-journal" ,there is no errors prompted. I think maybe the wdb-journal file was corrupted , does

Re: [sqlite] Query critique

2010-07-09 Thread Tim Romano
If you had the following tables Table PEOPLERANKINGS(personid INTEGER PRIMARY KEY, personname TEXT, ranking) Table FRIENDS(personid1, personid2) and an index on PEOPLERANKINGS.ranking and FRIENDS.personid1,FRIENDS.personid2 is a composite unique primary key You could get the top 10

Re: [sqlite] Retrieve Specific record number in one shot.

2010-07-09 Thread Jay A. Kreibich
On Fri, Jul 09, 2010 at 08:12:20AM -0300, Israel Lins Albuquerque scratched on the wall: > Maybe do you want this! > > http://www.sqlite.org/syntaxdiagrams.html#select-stmt > > Select * From Product order by ProductName LIMIT 210 OFFSET 210; Close, but not quite. This will return rows

Re: [sqlite] Retrieve Specific record number in one shot.

2010-07-09 Thread Igor Tandetnik
Piyush Verma wrote: > I want to navigate to specific position in table for example I want > row number 210 inspite of nevigating one by one how can get that row. See if this helps: http://www.sqlite.org/cvstrac/wiki/wiki?p=ScrollingCursor -- Igor Tandetnik

Re: [sqlite] Retrieve Specific record number in one shot.

2010-07-09 Thread Israel Lins Albuquerque
Maybe do you want this! http://www.sqlite.org/syntaxdiagrams.html#select-stmt Select * From Product order by ProductName LIMIT 210 OFFSET 210; - "Piyush Verma" escreveu: > Hello All, > > I want to navigate to specific position in table for example I want > row

Re: [sqlite] Query critique

2010-07-09 Thread Benoit Mortgat
On Fri, Jul 9, 2010 at 11:08, Ian Hardingham wrote: > Hey guys. > > I have a query which is very slow, and was wondering if there was any > advice you guys had on it. > > Here are two table definitions: > > CREATE TABLE IF NOT EXISTS globalRankingTable (id INTEGER PRIMARY KEY >

Re: [sqlite] Re trieve Specific record number in one shot.

2010-07-09 Thread Igor Sereda
Would Select * From Product order by ProductName LIMIT 1 OFFSET 209 help? -- Igor Piyush Verma-3 wrote: > > Hello All, > > I want to navigate to specific position in table for example I want > row number 210 inspite of nevigating one by one how can get that row. > > One way could be

[sqlite] Query critique

2010-07-09 Thread Ian Hardingham
Hey guys. I have a query which is very slow, and was wondering if there was any advice you guys had on it. Here are two table definitions: CREATE TABLE IF NOT EXISTS globalRankingTable (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL UNIQUE, ranking TEXT, score REAL, record TEXT);

[sqlite] Retrieve Specific record number in one shot.

2010-07-09 Thread Piyush Verma
Hello All, I want to navigate to specific position in table for example I want row number 210 inspite of nevigating one by one how can get that row. One way could be create a Index and use where clause to get that But it's not useful in my case. I have table which have primary key, and product

Re: [sqlite] importing data from file with 3 colums to table with 4 columns

2010-07-09 Thread Simon Davies
On 9 July 2010 06:18, wrote: > > > Thank you very much Simon. > > That worked very slick. > > > > Say, is there a way to put all of the SQLite3 commands  I used into a script > and have SQLite3 execute them in the script sequentially? > Yes, several ways: use .read command