Re: [sqlite] Computed columns in VIEWs return NULL but should be able to be typed! Any ideas?

2010-05-06 Thread Dan Bishop
Stefan Keller wrote: > Thank you, Tom and Dan, for your constructive answers. > > To Pavel: My application reads the column types out in order to pretty > print the values - as mentioned by Tom - but also to generate a dialog > for entering new data (of course combined with INSTEAD OF TRIGGERs). >

Re: [sqlite] One more on .import

2010-05-06 Thread Matt Young
Righto yes, a simple macro somewhere in the path to correct for row size On 5/6/10, Jim "Jed" Dodgen wrote: > On Thu, May 6, 2010 at 3:56 PM, Simon Slavin wrote: >> >> On 6 May 2010, at 11:19pm, Matt Young wrote: >> >>> I need a version of import that reads what it can, filling in defaults >>> w

Re: [sqlite] One more on .import

2010-05-06 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/06/2010 04:55 PM, Matt Young wrote: > It could be done and only adds a few bytes to the binary since the > code would simply check the 'ignore on import setting of .mode' before > taking error action for missing or too many columns. The issue i

Re: [sqlite] One more on .import

2010-05-06 Thread Jim "Jed" Dodgen
On Thu, May 6, 2010 at 3:56 PM, Simon Slavin wrote: > > On 6 May 2010, at 11:19pm, Matt Young wrote: > >> I need a version of import that reads what it can, filling in defaults >> when too few columns, discarding data when too many. > > Great.  Go ahead and write one.  You have our permission. > >

Re: [sqlite] One more on .import

2010-05-06 Thread Matt Young
It could be done and only adds a few bytes to the binary since the code would simply check the 'ignore on import setting of .mode' before taking error action for missing or too many columns. I will look at the source On 5/6/10, Simon Slavin wrote: > > On 6 May 2010, at 11:19pm, Matt Young wrote:

Re: [sqlite] Computed columns in VIEWs return NULL but should be able to be typed! Any ideas?

2010-05-06 Thread Stefan Keller
Thank you, Tom and Dan, for your constructive answers. To Pavel: My application reads the column types out in order to pretty print the values - as mentioned by Tom - but also to generate a dialog for entering new data (of course combined with INSTEAD OF TRIGGERs). I understand that it's difficul

Re: [sqlite] One more on .import

2010-05-06 Thread Simon Slavin
On 6 May 2010, at 11:19pm, Matt Young wrote: > I need a version of import that reads what it can, filling in defaults > when too few columns, discarding data when too many. Great. Go ahead and write one. You have our permission. Simon. ___ sqlite-us

Re: [sqlite] ANN: O'Reilly book "Using SQLite" available for pre-order

2010-05-06 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/04/2010 07:30 PM, Doug wrote: > Sure, if the book is just a copy-paste of the website, > that's not too helpful. But hopefully things are stated differently, or > examples are given which can be valuable. I picked some random spots to check: "

[sqlite] One more on .import

2010-05-06 Thread Matt Young
I need a version of import that reads what it can, filling in defaults when too few columns, discarding data when too many. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Virtual tables

2010-05-06 Thread Matt Young
Got that one two, thanks, this mail list saves time. On 5/6/10, Jay A. Kreibich wrote: > On Thu, May 06, 2010 at 12:31:26AM -0700, Matt Young scratched on the wall: > >> Can I create a virtual table mapped to an existing table in my >> database? > > You'll need to write a fair amount of code, b

Re: [sqlite] SELECT question (computing day of week the usingstrftime() function)

2010-05-06 Thread Kees Nuyt
On Wed, 05 May 2010 20:37:17 -0500, Ed Sims wrote: >Please cancel my subscription to this list!! My Mail client is overwhelmed. Hi Ed, Only you can unsubscribe. Read the instructions in the welcome message you received when you subscribed. Or visit the website listed at the bottom of every mess

Re: [sqlite] virtual tables, how experimental? what's the history of it?

2010-05-06 Thread Jay A. Kreibich
On Thu, May 06, 2010 at 12:10:56PM -0700, Trey Jackson scratched on the wall: > So I was looking at the Virtual Table http://www.sqlite.org/vtab.html > Anyway, can someone provide history on how much has it has changed over > releases, when it was introduced? Just so I have some contextual basi

Re: [sqlite] virtual tables, how experimental? what's the history of it?

2010-05-06 Thread Richard Hipp
On Thu, May 6, 2010 at 3:10 PM, Trey Jackson wrote: > All, > > Am starting to look at using sqlite in our organization. For some of the > data we work with it's a no-brainer > to dump the data into sql and use sql as our storage mechanism. However, a > large amount of the data generated > by ou

[sqlite] virtual tables, how experimental? what's the history of it?

2010-05-06 Thread Trey Jackson
All, Am starting to look at using sqlite in our organization. For some of the data we work with it's a no-brainer to dump the data into sql and use sql as our storage mechanism. However, a large amount of the data generated by our tool is (and will be) stored in our own custom formats. So I was

Re: [sqlite] Returning column to default

2010-05-06 Thread Andy Gibbs
Adam, > Is there a primary key on the table? > > Is it possible to use insert or replace instead of update, and then not > reference the column you want to set as a default? An interesting idea. Unfortunately, I think in my case it would be too much of a performance hit since I would be updatin

Re: [sqlite] Returning column to default

2010-05-06 Thread Adam DeVita
Is there a primary key on the table? Is it possible to use insert or replace instead of update, and then not reference the column you want to set as a default? On Thu, May 6, 2010 at 10:41 AM, Andy Gibbs wrote: > > You could write a trigger that sets default value if NULL is inserted > > or set

Re: [sqlite] Returning column to default

2010-05-06 Thread Andy Gibbs
> You could write a trigger that sets default value if NULL is inserted > or set via UPDATE. That's a great idea - thanks! It won't work in all the places since in some places 'NULL' is a valid value, but I'm sure I can think of a work-around. Thank you!! __

Re: [sqlite] Returning column to default

2010-05-06 Thread Andy Gibbs
Thanks for the speedy response. Unfortunately, it's not seemingly possible to do... UPDATE tab SET col = (SELECT dflt_value FROM (PRAGMA table_info(tab))); ... which certainly does make it a pain. Plus this doesn't work anyway where dflt_value is not a constant, but an expression (e.g. "curren

Re: [sqlite] Returning column to default

2010-05-06 Thread Pavel Ivanov
> I know it would be possible to simply hard-code the default value into the > UPDATE statement, but this would mean when updating the default in the table > declaration, I then need to make sure all the UPDATEs match! You could write a trigger that sets default value if NULL is inserted or set

Re: [sqlite] Returning column to default

2010-05-06 Thread Jay A. Kreibich
On Thu, May 06, 2010 at 04:11:43PM +0200, Andy Gibbs scratched on the wall: > Is it possible to do this in sqlite? No. > I know it would be possible to simply hard-code the default > value into the UPDATE statement, but this would mean when > updating the default in the table declaration, I t

[sqlite] Returning column to default

2010-05-06 Thread Andy Gibbs
Hi, I hope I haven't missed something in the documentation, but I can't find a statement to return a column value to its default. If I have the following table: CREATE TABLE tab (col TEXT DEFAULT "some_default", ); I can insert with defaults using INSERT INTO tab DEFAULT VALUES But there

Re: [sqlite] Should this work?

2010-05-06 Thread Tim Romano
elaboration: " ... you could this (to find the set to be inserted): " TR ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] Should this work?

2010-05-06 Thread Tim Romano
I don't understand why you are simulating distinct. Either something is going completely over my head (quite possible) or you are making things harder than they need to be. If you want to insert into T1 a distinct set of rows from T2 that don't already exist in T1, you could do this: select dis

Re: [sqlite] Should this work?

2010-05-06 Thread Matt Young
Got it, thinks Jay. On 5/6/10, Jay A. Kreibich wrote: > On Thu, May 06, 2010 at 05:10:31AM -0700, Matt Young scratched on the wall: >> OK, I got it. >> >> insert into seriesid >> select series_id,min(ROWID) from >> seriesdata group by series_id; >> >> This gets me a table with a pointe

Re: [sqlite] where may I find a simple sqlitecopy

2010-05-06 Thread Jay A. Kreibich
On Thu, May 06, 2010 at 12:02:13PM +0200, marcos rebelo scratched on the wall: > Hy all > > I need to do a sqlite backup every 2 hours, so I was looking for some > sort of sqlitecopy tool that would work from the shell. See the .backup and .restore commands in a current version of sqlite3. T

Re: [sqlite] Should this work?

2010-05-06 Thread Jay A. Kreibich
On Thu, May 06, 2010 at 05:10:31AM -0700, Matt Young scratched on the wall: > OK, I got it. > > insert into seriesid > select series_id,min(ROWID) from > seriesdata group by series_id; > > This gets me a table with a pointer to the firs instance of series_id > in the bigger table hav

Re: [sqlite] Virtual tables

2010-05-06 Thread Jay A. Kreibich
On Thu, May 06, 2010 at 12:31:26AM -0700, Matt Young scratched on the wall: > Can I create a virtual table mapped to an existing table in my > database? You'll need to write a fair amount of code, but yes. > Does this let me alias a whole table? It lets you do pretty much anything you wan

Re: [sqlite] Should this work?

2010-05-06 Thread Matt Young
OK, I got it. insert into seriesid select series_id,min(ROWID) from seriesdata group by series_id; This gets me a table with a pointer to the firs instance of series_id in the bigger table having multiple copies, it assumes that the ids are contiguous, allowing me to use offset,

Re: [sqlite] where may I find a simple sqlitecopy

2010-05-06 Thread Alexey Pechnikov
For incremental copy may be useful the sqlite3-rdiff utility: http://sqlite.mobigroup.ru/src/wiki?name=sqlite3-rdiff -- Best regards, Alexey Pechnikov. http://pechnikov.tel/ ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cg

Re: [sqlite] Should this work?

2010-05-06 Thread Simon Davies
On 6 May 2010 12:03, Matt Young wrote: > # I am doing a simulation of distinct > > insert into seriesid (series_id,pointer) >        select  series_id,ROWID from seriesdata as s >                where s.series_id not in( >                select >                        series_id >                f

Re: [sqlite] Should this work?

2010-05-06 Thread Fredrik Karlsson
Hi, Have you had a look at the EXCEPT statement? http://www.sqlite.org/lang_select.html (bottom of page) "EXCEPT takes the result of left SELECT after removing the results of the right SELECT. " Does this make sense to you? /Fredrik On Thu, May 6, 2010 at 1:03 PM, Matt Young wrote: > # I am d

Re: [sqlite] Suggestions on optimising this

2010-05-06 Thread Simon Slavin
On 6 May 2010, at 10:35am, Ian Hardingham wrote: > CREATE TABLE IF NOT EXISTS globalRankingTable (id INTEGER PRIMARY KEY > AUTOINCREMENT, name TEXT NOT NULL UNIQUE, ranking TEXT, score REAL, > record TEXT); > > And a "friends" table which looks like this: > > CREATE TABLE IF NOT EXISTS friend

[sqlite] Should this work?

2010-05-06 Thread Matt Young
# I am doing a simulation of distinct insert into seriesid (series_id,pointer) select series_id,ROWID from seriesdata as s where s.series_id not in( select series_id from seriesid

Re: [sqlite] Suggestions on optimising this

2010-05-06 Thread Pavel Ivanov
> For a query like that in a single-threaded application, I don't need to > mess about with sessions or anything correct? Did you mean transactions here? You don't need to think about transactions when selecting unless you want to make several queries and need to be sure that no changes is made to

Re: [sqlite] Suggestions on optimising this

2010-05-06 Thread Ian Hardingham
Thanks Pavel, much appreciated. For a query like that in a single-threaded application, I don't need to mess about with sessions or anything correct? Thanks, Ian Pavel Ivanov wrote: > If your simpleId is a concatenation of player and friend then I'd > suggest to remove that colunm and add uniqu

[sqlite] FTS3 performance problem

2010-05-06 Thread NomadLibra
Dears FTS3 performance is acceptable for SQLite 3.6.20 when the FTS virtual table contains 10K~100K records. (Query speed: 20K records/ 0.4831sec) but the performance is bad for SQLite 3.6.21~3.6.23.1 (Query speed: 20K records/ > 7sec) The query is simple: *SELECT docid FROM XTable WHERE XTable M

Re: [sqlite] I don't understand locking

2010-05-06 Thread Pavel Ivanov
And in addition to Dan's words: if you change "BEGIN" to "BEGIN IMMEDIATE" your code will work as you expect it to. Pavel On Thu, May 6, 2010 at 12:41 AM, Dan Kennedy wrote: > > On May 5, 2010, at 8:32 PM, myomancer wrote: > >> Dear Users >> >> I've spent hours reading various web-based documen

Re: [sqlite] Suggestions on optimising this

2010-05-06 Thread Pavel Ivanov
If your simpleId is a concatenation of player and friend then I'd suggest to remove that colunm and add unique constraint on pair of columns (player, friend). If your simpleId is not the same then remove it anyway, add column current_user and add unique constraint on (current_user, friend). After t

[sqlite] where may I find a simple sqlitecopy

2010-05-06 Thread marcos rebelo
Hy all I need to do a sqlite backup every 2 hours, so I was looking for some sort of sqlitecopy tool that would work from the shell. It shall be easy to do it with the Online Backup API. In case of not existing one tool like that already done, does someone has Perl/DBI code doing this work? Tha

Re: [sqlite] Read-only tables in in-memory database?

2010-05-06 Thread Andy Gibbs
How about hitting your injection problem from the other side? Perhaps you can validate the data that is going in to making up your query. I don't know what query in particular you are using, but it made me think and something that cannot work with parameterisation could be something like the f

[sqlite] Suggestions on optimising this

2010-05-06 Thread Ian Hardingham
Hey guys. I have an 1000 row table that looks like this: CREATE TABLE IF NOT EXISTS globalRankingTable (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL UNIQUE, ranking TEXT, score REAL, record TEXT); And a "friends" table which looks like this: CREATE TABLE IF NOT EXISTS friendTable

Re: [sqlite] Read-only tables in in-memory database?

2010-05-06 Thread Alexey Pechnikov
See http://sqlite.mobigroup.ru/src/wiki?name=WClark To use READONLY, it should form part of a constraint clause for the column. So, for example: CREATE TABLE t (i integer readonly); or CREATE TABLE t (i integer constraint my_constraint readonly); READONLY stops the value being modified through a

Re: [sqlite] Virtual tables

2010-05-06 Thread Andy Gibbs
I don't think there is anything in the vanilla sqlite to do this, but... Have a look at src/test8.c in the main (not amalgamation) source code... this may give you some ideas. I don't think it does what you want exactly, but a quick skim through makes me think it has some pointers in the right

[sqlite] Virtual tables

2010-05-06 Thread Matt Young
Can I create a virtual table mapped to an existing table in my database? Does this let me alias a whole table? Thinking out loud, does this give me ability to write a query on the virtual table, then remap the virtual table to a current table and execute the query? ___