sqlite

Reading material on writing optimal SQL database queries

I have no idea whether my database queries are at all clean, efficient, and so on. At best, I can get what I need from the DB but not much else. What books (or websitse) should I read to move forward? I want to know about performance costs of the various conditions and keywords that could potentially go into a query (e.g. JOIN, IN, WHER...

Is there anyway to implement Full Text Search (FTS) in SQlite from Android platform?

I am trying to create an application which collects a lot of notes from users. I want to implement full text search on the notes so that the user can get relevant notes from the whole array of notes. I am looking for a solution for this. Full-text-search(FTS) is actually supported by SQLite, but is it available for Android? Can anybody ...

While Inserting records in SQLite returns -1

Hi all, This is my SimpleDBAdapter Class that encapsulates all the complexities of accessing the database and the inner class SimpleDBHelper takes care of CRUD operations,now the Problem that i am facing here is when i deploy the code, the tables were getting created, but the i am unable to insert tht values in to the table, the id is ...

How to insert a string in SQLite database without conversion ?

The table: CREATE TABLE configuration(Key STRING, Value STRING, PRIMARY KEY (Key) ); Here is what I tried: insert into configuration(Key,Value) values(42,cast('0042' as text)); Here is the dump: INSERT INTO "configuration" VALUES(42,42); What I wanted: INSERT INTO "configuration" VALUES(42,'0042'); ...

how to send database data to a MySQL server to update the server database.

Hi everyone, I am developing Smoking counter and I need to send all the smoking record (about the time user smoking) to database on the server. The server database is MySQL database. I knew that I must have send data to PHP page/script, and this page/script will run on the data to insert record to database. I would like to know: is the...

Check for specific column in Android SQLite database

I am trying to check if there is a specific column in my database when onUpgrade() gets called. Is there an easy way to check like if(database does not have specific column){ db.execSQL("ALTER TABLE table" + " ADD COLUMN column" ); } I saw some other answer, Pragma Table, but I don't know how to use it or even what it really is for. ...

Python. Output of crypto.cipher.blowfish and .AES can be translated neither into unicode (as sqlite wants), nor into hex.

Okay, I'm totally new to Python, so I decided to make a simple app. Here is my encryption function: from Crypto.Cipher import AES def encPass(login, password): keyPhr=os.environ['HOME']+login hashObj = hashlib.md5() hashObj.update(keyPhr) keyPhr=hashObj.hexdigest() keyObj=AES.new(keyPhr) encPwd=keyObj.encrypt(pas...

xCode Sqlite Database Creation Without Z_METADATA

When my sqlite database is created using a core data model, at this line: if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) I get an error: NSUnderlyingException=I/O SQLite error code:1, 'no such table: Z_METADATA' Any idea ...

Python doesn't save data to sqlite db.

This is my code: conn = sqlite3.connect(nnpcconfig.commondb) cur = conn.cursor() query = ['2124124', 'test2', 'test3', 'test4', 'test5'] cur.execute("insert into users(id, encpass, sname, name, fname) values (?, ?, ?, ?, ?)", query) conn.commit cur.execute("select * from users") for row in cur: print row This code works, returning...

no such column: _id SQLite error Android.

I'm getting a no such column: _id error. YES there is a column "_id" in my journals table. I'm getting the error with this code: mDb.execSQL("UPDATE "+DATABASE_PLANTS_TABLE+" SET "+ KEY_PLANT_DAYS+ " = (SELECT COUNT(*) FROM "+DATABASE_PLANTS_TABLE+" WHERE " +DATABASE_JOURNAL_TABLE+"."+KEY_JROWID+" = "+DATA...

SQLite 64-bit library crashes when sqlite3_prepare_v2 fails

I'm compiling both a 32-bit and 64-bit SQLite library with Microsoft Visual C++ from the command line for a simple C# wrapper. The 32-bit version works fine, but the 64-bit version crashes my application completely when sqlite3_prepare_v2 returns anything but SQLITE_OK. build.bat set ARGS=/nologo /LD /DSQLITE_ENABLE_COLUMN_METADATA sql...

Execute SQLite Inserts in several foreach loops in C# ?

Hello everybody, this is my code I have: I have read that setting up the CommandText should happen only once and not in a loop... but how do I then get the individually item data from the foreach? Someone smart enough to refactor that code, that would be nice :) using (SQLiteTransaction trans = DataAccess.ConnectionManager.BeginTrans...

Selecting the highest salary

Assuming a wagetable: name lowhours highhours wage Default 0.0 40.0 100 Default 40.0 50.0 150 Default 50.0 70.5 154 Default 70.5 100.0 200 Brian 0.0 40.0 200 Brian 40.0 50.0 250 Brian 50.0 60.0 275 Brian 60.0 7...

AutoCompleteTextView adapter not displaying dropdown?

Here is my onCreate method: /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent intent = getIntent(); if (intent.getData() == null) intent.setData(Formulas.CONTENT_URI); Au...

SQLite: Combining an OR and AND

This is continuing questions from http://stackoverflow.com/questions/3539673/sqlite-selecting-the-highest-salary Assuming a table 'wagetable' name lowhours highhours wage priority Default 0.0 40.0 100 0 Default 40.0 50.0 150 0 Default 50.0 70.5 154 0 D...

Error Creating Table on Android

I'm trying to create a table in android database, but when i try to run the application the LogCat returns the following error: 08-22 02:39:29.098: ERROR/AndroidRuntime(277): Caused by: android.database.sqlite.SQLiteException: near "auto_increment": syntax error: CREATE TABLE words(id INTEGER PRIMARY KEY, word TEXT, count INTEGER not nu...

Foreign key constraint that points to one of several tables

I have a table with one column source_id whose value should be the primary key of another table, though which table it is will vary from record to record. Every record must have a value for source_table that specifies the table for the source record, and a value for source_id that specifies the row in the source table. Is there any way ...

How to increment field in sqlite android database

Hey, I want to increment a column in a sqlite android database. Im doing like this: public void atualiza(String word){ this.db.rawQuery("UPDATE words SET count = count + 1 WHERE word= ? ", new String[] {word}); } And I call this method on another class like this: this.dh.atualiza(word); But when i pull the database from t...

Get 10 Random Records From SQLite Database

I haven't been able to find a very good way of getting 10 random records out of a sqlite database. Seen a few examples that work with mysql, but they don't seem to work well with sqlite even though I am trying to us Random() instead of rand(). I have tried to get random numbers and then get the records by id, but for some reason I am ge...

Occasionally online app data synchronisation

Hi, I am writing an application which consists of a master "server" database (most probably sqlite) and a client side replica with client specific records (again, Sqlite). The clients may only be online occasionally or may be on slow 3G connections; I need a solution to reliably synchronise content either on demand or at scheduled inter...