sqlite

How to create programmatically an index in a SQLite database with Xcode ?

I use in my iPhone application a very big database. An index is used on one of its columns in oder to make the searchs in this database faster. The problem is that this index increases the size of the database : my application is now bigger than 20 Mo requiring a wifi download (I would like to remain below 20 Mo in order to allow 3G down...

Checking duplicate while inserting in SQLite

Hello All, I am trying to insert a data into SQLite database using Python. INSERT INTO DATA_TABLE(UID,LABEL) VALUES (NULL, "UK") WHERE "UK" NOT EXISTS IN (SELECT LABEL FROM DATA_TABLE); This query is dynamically generated from Python and I am checking whether the date is already exist in the table before inserting and its not w...

SQLite Problem - Database path

Hello, I'm trying to select data from the database and I have the following code in place: Code: // Setup the database object sqlite3 *database; // Init the animals Array list = [[NSMutableArray alloc] init]; NSLog(@"documents path: ", documentsDir); NSLog(@"database path: ", databasePath); // Open the database from the users ...

how to get list of all column names from given table in sqlite 3 ? (table might be empty)

now I use: PRAGMA table_info(table_name) construct, but it don't allow me to narrow search result to only column names, as it turns out much of unwanted data. That is array of arrays Array ( [0] => Array ( [cid] => 0 [name] => id [type] => INTEGER [notnull] => 0 ...

Should I create an index on the columns if their values are used in functions ? (SQLite)

Hi ! I am working with a huge database and trying top optimize it. I was wondering if it will make any change to index the values that are used as criteria in the request, but through a function. For example I have this GPS coordinate table : -Node (#id,lat,lng) and this request : SELECT * FROM Node WHERE distance( lat, lng, $lat, ...

Verify the structure of a database? (SQLite in C++ / Qt)

Hello, I was wondering what the "best" way to verify the structure of my database is with SQLite in Qt / C++. I'm using SQLite so there is a file which contains my database, and I want to make sure that, when launching the program, the database is structured the way it should be- i.e., it has X tables each with their own Y columns, app...

sqlite3_prepare_v2 problem

Hello, I'm getting the following error: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* +[NSString stringWithUTF8String:]: NULL cString' on the line of code below: NSString *aName = [NSString stringWithUTF8String(char*)sqlite3_column_text(compiledStatement, 1)]; I'm not sure whats going on here,...

SQL query to count records.

I have a table EntryLog(Name String, CheckIn Boolean) I want to count the number of checkins against each name. How do I write a query to get the result as a single resultset? ...

sqlite: multi-column primary key with an auto increment column

I basically want to convert a table from mysql to sqlite with the following scheme: create table items ( id integer auto_increment, version integer default 0, primary key (id, version) ); Essentially, I want ID to auto increment whenever I insert anything into the table, with VERSION starting off at 0, but still allow multiple items w...

Problem with SQL statement

Hello, I have the following code: if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { // Setup the SQL Statement and compile it for faster access const char *sqlStatement = "select ZWAYPOINT_X, ZWAYPOINT_Y from ZWAYPOINT where ZMAP_ID %@", mapID; sqlite3_stmt *compiledStatement; if...

Embeddable databases and toplink

I'm trying to get toplink and jsqlite to work. But I get a similar error like this thread: http://stackoverflow.com/questions/906241/jpasqlite-problem Exception Description: SEQ_GEN_SEQUENCE: platform DatabasePlatform doesn't support NativeSequence. I'm not sure it jsqlite even works with toplink, since I couldn't find a description s...

Sync a local SQLite DB with a server SQLite DB

Is it possible, and if so how can I effectively sync a local database with a global one such that when an action is taken on the local version it is also made on the global database. Simply using version control to subvert the global is unacceptable because there could be several local copies of the database according to the number of p...

select arbitrary amount of rows with N distinct values in foreign key referenced column

The database schema is CREATE TABLE sites ( site_id INTEGER PRIMARY KEY AUTOINCREMENT, netloc TEXT UNIQUE NOT NULL, last_visited REAL DEFAULT 0, crawl_rate REAL DEFAULT 2, crawl_frequency REAL DEFAULT 604800, robots_txt TEXT DEFAULT 0, robots_last_fetch REAL DEFAULT ...

select query in sqlite

hey can some tell me the query in sqlite3 which can be used to select the entry only once if it exists more than once in my database ...

Improve performance of self join in sqlite

I have a table with 21 columns (all integers) id, c1 , c2 ... c20 and what to fetch ids for rows that have the same values in the columns ... so row 1 will match row 10 if row 1 c1 = row 10 c1 and row 1 c2 = row 10 c2 ... and so on. This is what the query looks like: select r1.id, r2.id from tbl r1, tbl r2 where 1=1 and r1.c1=r...

What is an index in SQLite?

I don't understand what an index is or does in SQLite. (NOT SQL) I think it allows for sorting in acending and decending order and access to data quicker. But I'm just guessing here. ...

How to implement a foreign key in SQLite

How can I implement a foreign key in SQLite? I was thinking something like this: CREATE TABLE job (_id INTEGER PRIMARY KEY AUTOINCREMENT, employer_id INTEGER, ...); CREATE TABLE employer(_id INTEGER, employer_name TEXT NOT NULL, ...); Where employer_id is the _id from the table employer. Would this work? Is there another fast, maybe ...

android with sqlite

can anybody give example how to connect sqlite with android? Thanks in advance ...

Sqlite doesn't seem to like my delete statement

I've got the following iphone code, which seems to be failing: sqlite3_stmt *dbps; NSString *sql = @"delete from days where day=?1;insert into days(disabled,recipe_id,day) values(?2,?3,?1)"; int rc = sqlite3_prepare_v2(db, sql.UTF8String, -1, &dbps, NULL); ... The 'rc' return code is 1, meaning SQLITE_ERROR (SQL error or missing datab...

Performance Issues with ActiveRecord / NHibernate and SQL CE

Hello, Our team is currently working on a WPF Desktop application with ActiveRecord and SQLCE 3.5 for backend. We've been experiencing some strange performance issues when executing queries or creating/updating records. In some cases opening a form which has a few grids and data elements that need to be populated, can take around 2 seco...