sqlite3

Parsing SQL file in Objective-C

Does anyone know of an Objective-C library that will easily allow developers to parse a SQL file? I am building an iPhone application that contains a SQLite database and I am attempting to come with a system to upgrade a user's writable database. After reading a lot of the questions and answers on this site it appears that the best way t...

Trouble with SQLite SQL Query

I'm trying to run the following query in SQLite 3: SELECT *, DISTANCE(latitude, longitude, ?, ?) AS "distance" FROM "country" WHERE "id" NOT LIKE ? HAVING "distance" <= ? ORDER BY "distance" ASC; But I get the following error: SQLSTATE[HY000]: General error: 1 a GROUP BY clause is required before HAVING I don't understand ...

How to count many things with SQLite under Perl ?

I want to count many strings (>3G), so I choose SQLite with a table of (str TEXT PRIMARY KEY, count INTEGER DEFAULT 1). There are about 3G strings, each takes 40*2/8=10 bytes, thus the whole strings is 30GB. Of those 10 bytes, there are 2^80 kinds, which is much larger than 3G. So how to update effectively ? UPDATE table SET count = c...

What's the best way to do one-way synching from a server-side database to iPhone?

I've got a database on my server which is about 3mb big. I'd like to ship that with my iphone application. The most important thing is that I'd like to promote changes to the database (insert, updates, deletes) to the iphone. What's the best way of doing that? I mean - what is necessary on - the server - the client (= iphone) - between;...

SQLITE3 2 level join with aggreation on middle level

we have 3 tables: grandfathers, fathers, sons. grandfathers have many fathers, and fathers have many sons, through the foreing keys grandfather_id and father_id. Each record has only one property, the name of the person. What I want is to have a list of all grandfathers, each with a field called grandsons_names which is the csv of all ...

SQLite3 Doesn't Produce an Aggregation Error on Malformed/Indeterminate Queries?

SQLite behaves differently when dealing with aggregation than many other RDBMS's. Consider the following table and values: create table foo (a int, b int); insert into foo (a, b) values (1, 10); insert into foo (a, b) values (2, 11); insert into foo (a, b) values (3, 12); If I query it thus: select a, group_concat(b) from foo; Norm...

Get Rows Where timestamp Column is 2 days Old

Hey guys, I have a table that has a column with the timestamp in sqlite3. It is default to the CURRENT_TIMESTAMP such that when the row gets inserted, the current time is inserted. Now I am trying to fetch the rows that have been inserted 2 days ago or more. I wonder if that makes any sense. Reading the documentation I came up with: SE...

Clustered vs NonClustered Primary Key

begin transaction; create table person_id(person_id integer primary key); insert into person_id values(1); ... snip ... insert into person_id values(50000); commit; This code takes about 0.9 seconds on my machine and creates a db file taking up 392K. These numbers become 1.4 seconds and 864K if I change the second line to create table ...

SQLite and R interaction

I'm using the SQlite package to interface with a database from R. However, I'm running into the issue that the results from exactly the same query are different when I run it in R or from the command-line interface. For instance, the minimum value in a column is 0, but R somehow gives the result -2147332296. As I just copy-n-paste the q...

sqlite3 close statement is not working

I'm using a C program with sqlite3. Some times insert works.But sometime ,its not working. assert(retval == SQLITE3_OK) gives error. while debugging I found retval value of sqlite3_step() is error code = 5 which refers to Database file is busy Even closing with sqlite3_close() return error code 5. Any thoughts on how to close the data...

Convert datetime fields in Chrome history file (sqlite) to readable format

Working on a script to collect users browser history with time stamps ( educational setting). Firefox 3 history is kept in a sqlite file, and stamps are in UNIX epoch time... getting them and converting to readable format via a SQL command in python is pretty straightforward: sql_select = """ SELECT datetime(moz_historyvisits.visit_date...

sqlite3 close returns error code 5

While closing sqlite3 using sqlite3_close function it returns error code 5 5 - database file is busy. How to fix this issue. ...

Floats are not saved correctly into SQLite table using PHP

Hi, I'm using SQLite 3 with PHP. The SQLite table consists of 2 INTEGER and one FLOAT column. When saving data into this table using PHP floats are not saved correctly (default value is stored instead). The two integer columns are saved. Any ideas what could be wrong? Thank you. Simplified code that actually works correctly: $conn = n...

Why does SQLite not bring back any results from my database

This is my first SQLite based iPhone app and I am trying to get it to read a menu hierarchy from my database. The database appears to be registered fine as the compiled statement doesnt error (tried putting in valid table name to test) but for some reason sqlite3_step(compiledStmt) doesnt ever equal SQLITE_ROW as if to suggest there is ...

Does SQLite have a machine portable file format that the C API can read/write?

I've tried passing binary SQLite DBs over the network between different OSes and architectures - it didn't work. What format are you all using? I've tried an unholy hack of copying SQLite's shell.c and calling shell_main() with a hacked up argc, argv, stdin with success on Mac. Pity I'm developing for the iPhone and it fails only there....

how to save time from compiling whole project ?

I am implementing some idea on sqlite3. Every time I want to test my codes, I have to compile the whole project. The following is exactly what I do : sudo make uninstall sudo make clean ./configure sudo make sudo make install some of above commands cost long time. What should I do to save time? ...

Need help with writing a SQLite3 Objective-C resultset wrapper

Hi, I am trying to write a sqlite resultset wrapper class for the iPhone, and I would like to be able to dynamically call sqlite3_column_int or sqlite3_column_text? For example, in my fetchAll method, I would like to not know what exact data i'm returning, I just want to return it. My goal is to have a class that doesn't care what da...

Subsonic 3 + SQLite 3

I am trying to use Subsonic for SQLite. I got an exception "SQLite error near ".": syntax error". VS 2008; Subsonic 3.0.0.3; SQLite 3. How I can to resolve it? Also, cananybody provide an project example with Subsonic for SQLite included. ...

iPhone Sqlite access issue

Hi all, I have build an iPhone app which is currently in the app store and I am preparing an update for it. The app saves information in a sqlite database and because the DB structure has changed significantly in the update I am now trying to migrate the information from the old DB to the new one. Everything works smoothly when I do t...

Database + Sync (Iphone app)

Hi, How can I flush my sqlite database in my application when I click on a button? I already have a database inside my app, when I click on a button it add some data into it. I wanna know how to fluch the database after I click the button or maybe restart the application automatically. Thanks, ...