Re: [sqlite] BUG using DELETE query with AND clause
Ticket: https://www.sqlite.org/src/info/ef36060112a50591 On 8/26/16, Алексей Черныхwrote: > DELETE statement has no effect on existing data, if AND clause used and > values > are in ' escape chars. > > OS: Ubuntu 16 (updated) > > #sqlite3 -version > #3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f > > Bug is reproduced in our database with a hundred of tables, but it is easy > to > reproduce on single table with foreign keys replaced with integer field, so > the > way to reproduce (BUG itself is on 5th step): > > 1. sqlite3 /root/testdb > > 2. CREATE TABLE aps_assign( id INT NOT NULL, aps INT NOT NULL, webdomain INT > NOT NULL, path VARCHAR(255), CONSTRAINT aps_assign_primary_key PRIMARY KEY > (id) ON CONFLICT FAIL); > > 3. INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('1', '1', > '1000', > '/path1'); > INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('2', '2', '2000', > '/path2'); > INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('3', '3', '3000', > '/path3'); > INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('4', '4', '4000', > '/path4'); > > 4. SELECT * FROM aps_assign WHERE id='4' AND webdomain='4000'; > id|aps|webdomain|path > 4|4|4000|/path4 > > 5. BUG HERE: Statement > DELETE FROM aps_assign WHERE id='4' AND webdomain='4000'; > does not delete anything > > 6. After DELETE execute: > SELECT * FROM aps_assign WHERE id='4' AND webdomain='4000'; > and see: > id|aps|webdomain|path > 4|4|4000|/path4 > record is on its place > > 7. Try to delete by fields without ' chars: > DELETE FROM aps_assign WHERE id=4 AND webdomain=4000; > SELECT * FROM aps_assign WHERE id='4' AND webdomain='4000'; > see record deleted here > > 8. Try to delete by one of fields: > DELETE FROM aps_assign WHERE id='3'; > SELECT * FROM aps_assign WHERE id='3'; > see record deleted here > > 9. Try to delete by other: > DELETE FROM aps_assign WHERE webdomain='2000'; > SELECT * FROM aps_assign WHERE webdomain='2000'; > see record deleted here > > So, we see: > If DELETE statement has '-marks and AND clause, the bug is reproduced. > > Additionally: > > SELECT * FROM aps_assign WHERE id=1 AND webdomain='1000'; > id|aps|webdomain|path > 1|1|1000|/path1 > > sqlite> DELETE FROM aps_assign WHERE id=1 AND webdomain='1000'; << this does > not delete row > sqlite> SELECT * FROM aps_assign WHERE id=1 AND webdomain='1000'; > id|aps|webdomain|path > 1|1|1000|/path1 > > sqlite> SELECT * FROM aps_assign WHERE id='1' AND webdomain=1000; > id|aps|webdomain|path > 1|1|1000|/path1 > > sqlite> DELETE FROM aps_assign WHERE id='1' AND webdomain=1000; << this > deletes row > sqlite> SELECT * FROM aps_assign WHERE id='1' AND webdomain=1000; << record > deleted > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] BUG using DELETE query with AND clause
DELETE statement has no effect on existing data, if AND clause used and values are in ' escape chars. OS: Ubuntu 16 (updated) #sqlite3 -version #3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f Bug is reproduced in our database with a hundred of tables, but it is easy to reproduce on single table with foreign keys replaced with integer field, so the way to reproduce (BUG itself is on 5th step): 1. sqlite3 /root/testdb 2. CREATE TABLE aps_assign( id INT NOT NULL, aps INT NOT NULL, webdomain INT NOT NULL, path VARCHAR(255), CONSTRAINT aps_assign_primary_key PRIMARY KEY (id) ON CONFLICT FAIL); 3. INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('1', '1', '1000', '/path1'); INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('2', '2', '2000', '/path2'); INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('3', '3', '3000', '/path3'); INSERT INTO aps_assign (id, aps, webdomain, path) VALUES ('4', '4', '4000', '/path4'); 4. SELECT * FROM aps_assign WHERE id='4' AND webdomain='4000'; id|aps|webdomain|path 4|4|4000|/path4 5. BUG HERE: Statement DELETE FROM aps_assign WHERE id='4' AND webdomain='4000'; does not delete anything 6. After DELETE execute: SELECT * FROM aps_assign WHERE id='4' AND webdomain='4000'; and see: id|aps|webdomain|path 4|4|4000|/path4 record is on its place 7. Try to delete by fields without ' chars: DELETE FROM aps_assign WHERE id=4 AND webdomain=4000; SELECT * FROM aps_assign WHERE id='4' AND webdomain='4000'; see record deleted here 8. Try to delete by one of fields: DELETE FROM aps_assign WHERE id='3'; SELECT * FROM aps_assign WHERE id='3'; see record deleted here 9. Try to delete by other: DELETE FROM aps_assign WHERE webdomain='2000'; SELECT * FROM aps_assign WHERE webdomain='2000'; see record deleted here So, we see: If DELETE statement has '-marks and AND clause, the bug is reproduced. Additionally: SELECT * FROM aps_assign WHERE id=1 AND webdomain='1000'; id|aps|webdomain|path 1|1|1000|/path1 sqlite> DELETE FROM aps_assign WHERE id=1 AND webdomain='1000'; << this does not delete row sqlite> SELECT * FROM aps_assign WHERE id=1 AND webdomain='1000'; id|aps|webdomain|path 1|1|1000|/path1 sqlite> SELECT * FROM aps_assign WHERE id='1' AND webdomain=1000; id|aps|webdomain|path 1|1|1000|/path1 sqlite> DELETE FROM aps_assign WHERE id='1' AND webdomain=1000; << this deletes row sqlite> SELECT * FROM aps_assign WHERE id='1' AND webdomain=1000; << record deleted ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
many thanks again for the replies and sorry I was amiss in not stating that it was sqlite3 DXCC.db, I was using the .db suffix but to no avail, however the problem has been that I was not getting it into the right folder to enter the import command. Thanks Bill you hit it on the nose, when bringing up the cmd screen it registered it was sitting at Users\John By entering cd C:\jt65Logger that put it into the correct folder and I was able to successfully import the test csv file, very simple but sadly overlooked by my ignorance. Alan ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Locking databases - Possibly (probably?) a dumb question
On 08/20/2016 01:01 PM, Simon Slavin wrote: > On 20 Aug 2016, at 5:56pm, Levwrote: [snip] >> So this 'setting' is stored in the database file? Is it enough to do the >> PRAGMA when the database is created? > > Yes and yes, but do it this way. > > 1) Create the database file by opening it. > 2) Do something that makes the file non-blank, like creating a table. > 3) Issue "PRAGMA journal_mode=WAL" > 4) Close the file > > From that point onwards that database is in WAL mode and everything opening > it automatically knows that. You do the above sequence using your own > software or the SQLite command-line shell tool. When in WAL mode, when would `PRAGMA synchronous = NORMAL` be issued and does it persist? ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] `SELECT FROM ( subquery ) alias` seems to require `AS`
On 8/24/16, Richard Newmanwrote: > sqlite> SELECT DISTINCT inner.uri AS uri FROM >...> (SELECT DISTINCT v AS uri FROM bar) >...> inner; > Error: near ";": syntax error > "Inner" is a keyword. You can put it in double-quotes to let SQLite know that you want to use it as an identifier, or you can use a different name like "xinner". -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] `SELECT FROM ( subquery ) alias` seems to require `AS`
Please retry your test without using keywords like "inner" as an alias for something. regards, Adam On Wed, Aug 24, 2016 at 11:26 PM, Richard Newmanwrote: > Hi folks, > > According to my reading of < > https://www.sqlite.org/syntax/table-or-subquery.html>, a table alias for a > subquery does not require an AS; that is, > > SELECT noo.foo FROM ( SELECT … FROM bar ) AS noo > > > is equivalent to > > SELECT noo.foo FROM ( SELECT … FROM bar ) noo > > > This does not seem to be the case with 3.14.1: > > SQLite version 3.14.1 2016-08-11 18:53:32 > Enter ".help" for usage hints. > sqlite> CREATE TABLE bar (e BLOB, a BLOB, v BLOB); > sqlite> SELECT DISTINCT inner.uri AS uri FROM >...> (SELECT DISTINCT v AS uri FROM bar) >...> AS inner; > sqlite> SELECT DISTINCT inner.uri AS uri FROM >...> (SELECT DISTINCT v AS uri FROM bar) >...> inner; > Error: near ";": syntax error > > > Am I misreading the docs, or is this a bug? > > Thanks, > > -Richard > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- -- VerifEye Technologies Inc. 151 Whitehall Dr. Unit 2 Markham, ON L3R 9T1 ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] System.Data.SQLite and Entity framework 5
Is there a way to work with System.Data.SQLite with Entity framework 5? Latest version for .net framework 4.5 requires EF6, bit I need to work with EF5. Thanks! ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] `SELECT FROM ( subquery ) alias` seems to require `AS`
Hi folks, According to my reading of < https://www.sqlite.org/syntax/table-or-subquery.html>, a table alias for a subquery does not require an AS; that is, SELECT noo.foo FROM ( SELECT … FROM bar ) AS noo is equivalent to SELECT noo.foo FROM ( SELECT … FROM bar ) noo This does not seem to be the case with 3.14.1: SQLite version 3.14.1 2016-08-11 18:53:32 Enter ".help" for usage hints. sqlite> CREATE TABLE bar (e BLOB, a BLOB, v BLOB); sqlite> SELECT DISTINCT inner.uri AS uri FROM ...> (SELECT DISTINCT v AS uri FROM bar) ...> AS inner; sqlite> SELECT DISTINCT inner.uri AS uri FROM ...> (SELECT DISTINCT v AS uri FROM bar) ...> inner; Error: near ";": syntax error Am I misreading the docs, or is this a bug? Thanks, -Richard ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
Various notes -At the prompt, running "sqlite3 DXCC" is starting the sqlite3 program, and telling it to open the file named "DXCC" as its database. If it's not given a full path then it opens it in the directory the command prompt is in when you run it. If the file you give it doesn't exist, then SQLite will create it after the first command that would require data to be written. So in whatever folder your command prompt opens up to there's probably a new file there called "DXCC". -Having file extensions off is a cause of many headaches. (Long running major pet peeve of mine that MS made it default to hidden) When you type "sqlite3 DXCC" you're telling it to use the file "DXCC". Specifically, you're telling it to use "DXCC.db" or "DXCC.sqlite" or "DXCC.something". You need to give it the exact file name. So if you have an existing file in there called "DXCC.db" where Windows "recognizes" the file type and hides it in Windows Explorer, and you type "sqlite3 DXCC" then it's not going to open the .db file, it'll make a new extensionless "DXCC" file. So, however you get to "Folder Options" in Windows 10, go there, then to the View tab, then make sure "Hide extensions for known file types" is turned off. -If you have Windows Explorer open you can open a new command prompt right to a specific folder by holding shift and right clicking on the folder, then select "Open command window here". This is an alternative to cd-ing to the folder from a default starting location. -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Alan Sent: Thursday, August 25, 2016 1:59 AM To: SQLite mailing list Subject: Re: [sqlite] sqlite importing csv I have created a directory for the project I am working on, and the Database and the csv file both reside in that directory. I right Clicked on start and selected the windows cmd, and as I understand it at the moment by typing sqlite3 DXCC then it should be sitting in the directory or folder that the DXCC database is in so should accept the sqlite command to import the csv file that is also sitting in that directory. I also tried it with the Admin cmd. On 25-Aug-16 16:38, Scott Robison wrote: > On Aug 24, 2016 10:25 PM, "Alan"wrote: >> forgot to reply to one of the questions. >> >> I am using version 3.13.0.0 and it is 64 bit >> >> I am running Windows 10 Pro >> >> computer is intel I3 3.5Ghz with 8Gb RAM. >> >> As my friend has no problem loading the same csv file with his Windows7 > computer >> I am guessing that it may be to do with running Windows 10. > What directory are you in? Are you using an elevated command prompt? > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQLite in VS2015 Server Explorer (Bugs)
Mr. Jensen, Thank you for the link - Although I am moving away from MS VS (I am using Dev-C++ more than MS VS) I have installed your MS VS Add-on so hopefully I will be able to use it soon. Thank you again Delvin -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Erik Ejlskov Jensen Sent: Thursday, 25 August, 2016 07:05 To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] SQLite in VS2015 Server Explorer (Bugs) As an alternative to the System.data.sqlite design tools (depending on your requirements) you can use my free VS extension "SQLite Toolbox" https://visualstudiogallery.msdn.microsoft.com/0e313dfd-be80-4afb-b5e9-6e74d369f7a1/ Mvh / Regards Erik Ejlskov Jensen http://twitter.com/erikej ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] SQLite in VS2015 Server Explorer (Bugs)
As an alternative to the System.data.sqlite design tools (depending on your requirements) you can use my free VS extension "SQLite Toolbox" https://visualstudiogallery.msdn.microsoft.com/0e313dfd-be80-4afb-b5e9-6e74d369f7a1/ Mvh / Regards Erik Ejlskov Jensen http://twitter.com/erikej ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
After opening your command prompt type: cd C:\jt65logger Then start SQLite and try importing your csv file. I see JT65 and DXCC, so I know this is ham related. Contact me directly if you'd like to discuss the ham aspects of your project. -- Bill Drago - W2KWD Staff Engineer L3 Narda-MITEQ 435 Moreland Road Hauppauge, NY 11788 631-272-5947 / william.dr...@l-3com.com > -Original Message- > From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On > Behalf Of Alan > Sent: Thursday, August 25, 2016 3:40 AM > To: sqlite users> Subject: Re: [sqlite] sqlite importing csv > > By the way I have a folder C:\jt65Logger that contains all the databases etc > to > do with the project. > > > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any attachments are solely for the use of the addressee and may contain information that is privileged or confidential. Any disclosure, use or distribution of the information contained herein is prohibited. In the event this e-mail contains technical data within the definition of the International Traffic in Arms Regulations or Export Administration Regulations, it is subject to the export control laws of the U.S.Government. The recipient should check this e-mail and any attachments for the presence of viruses as L-3 does not accept any liability associated with the transmission of this e-mail. If you have received this communication in error, please notify the sender by reply e-mail and immediately delete this message and any attachments. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
On 2016/08/25 9:35 AM, Alan wrote: Simon, I entered what you asaked and no, that file is in the users\John directory so I guess that the cmd sqlite3 DXCC is not shifting the focus to the directory that the DXCC database is in and i would need to be using some other set of commands to make that happen SQLite3.exe cannot (and shouldn't) shift focus of a folder. It can only access the DB file in the specified folder. You have to specify the folder of the imported file also. Since you noted newness - let me offer a quick word of advice - there is a chance the Windows "We'll protect your data from you" UAC virtualising will mess with your data in future if the program will run in anywhere deemed unsafe. You should start off with creating your data folder in the User space (C:\Users\yourUser\Appdata\Roaming\yourAppFolder\) to enjoy smooth sailing. There's a CMD shortcut to this directory of the user's too (I forgot now the actual name, but google can tell you). Cheers! Ryan ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
By the way I have a folder C:\jt65Logger that contains all the databases etc to do with the project. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
Simon, I entered what you asaked and no, that file is in the users\John directory so I guess that the cmd sqlite3 DXCC is not shifting the focus to the directory that the DXCC database is in and i would need to be using some other set of commands to make that happen Alan On 25-Aug-16 16:45, Simon Slavin wrote: On 25 Aug 2016, at 4:03am, Alanwrote: attempt to import a short test Excel table of two columns with about 4 records in it, the main one I was trying to import had the same trouble with, it had over 300 records in it with two columns. Issue this command: sqlite3 DXCC.sqlite then inside the SQLite shell tool do the following: CREATE TABLE testTable (testColumn TEXT); .once testoutput.txt .schema .quit Do you find a new file called 'testoutput.txt' in the same folder as your anr.csv file ? Assuming that you /do/ get the file you expected ... Open anr.csv using NOTEPAD. Does the file look like comma-separated values to you ? Is the top line a line of data (probably numbers) or does it have column names ? You're importing the data in that file into a table. Have you already defined the table in your SQLite database before you issue the .import command or are you expecting SQLite to create the table for you ? Simon. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
after clicking on the command it is in C:\users\john after typing sqlite3 DXCCit shows sqlite> if I then enter cd it shows ...> On 25-Aug-16 18:01, Simon Slavin wrote: On 25 Aug 2016, at 6:59am, Alanwrote: I right Clicked on start and selected the windows cmd, and as I understand it at the moment by typing sqlite3 DXCC then it should be sitting in the directory or folder that the DXCC database is in I don't think this is correct. Once you have started cmd instead of starting 'sqlite3', use this command 'cd'. It reports your current directory. Simon. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
I was just going to suggest that - if it is the default directory - windows will start the command prompt in the C:\users\. As long as the csv file is in this directory (but more than likely it is in the C:\users\\Documents directory. Delvin -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Simon Slavin Sent: Thursday, 25 August, 2016 01:02 To: SQLite mailing listSubject: Re: [sqlite] sqlite importing csv On 25 Aug 2016, at 6:59am, Alan wrote: > I right Clicked on start and selected the windows cmd, and as I understand > it at the moment > > by typing sqlite3 DXCC then it should be sitting in the directory or folder > that the DXCC database is in I don't think this is correct. Once you have started cmd instead of starting 'sqlite3', use this command 'cd'. It reports your current directory. Simon. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite importing csv
On 25 Aug 2016, at 6:59am, Alanwrote: > I right Clicked on start and selected the windows cmd, and as I understand > it at the moment > > by typing sqlite3 DXCC then it should be sitting in the directory or folder > that the DXCC database is in I don't think this is correct. Once you have started cmd instead of starting 'sqlite3', use this command 'cd'. It reports your current directory. Simon. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users