lundi 30 mars 2015

PHP SQLite password protected database

I am looking for a way to have a password protected SQLite Database being created and accessed throughout PHP. So far I found two ways to set a password in .NET (1, 2) but not in PHP...


If there is any way to do that, in PHP, please enlighten me!


How Connect SQLite Database to Android App (Eclipse)

I have create database on FireFox SQLite Manager and I want to connect this database to my application eclipse. Please help me for my thesis. Thanks.


Android Sqlite Error and unable to read data?

My apologies for the title, bcz i am not sure what kind of error it is but i am unable to read data from my sqlite db and getting this error in logcat.



03-30 22:55:07.555 27036-27470/com.example.app E/sqlite3_android﹕ CDF_MAX_DIGIT_MATCH = 100
03-30 22:55:07.555 27036-27470/com.example.app E/sqlite3_android﹕ CDF_MIN_DIGIT_MATCH = 7
03-30 22:55:07.561 27036-27470/com.example.app E/sqlite3_android﹕ CDF_MAX_DIGIT_MATCH = 100
03-30 22:55:07.561 27036-27470/com.example.app E/sqlite3_android﹕ CDF_MIN_DIGIT_MATCH = 7
03-30 22:55:07.565 27036-27470/com.example.app E/sqlite3_android﹕ CDF_MAX_DIGIT_MATCH = 100
03-30 22:55:07.565 27036-27470/com.example.app E/sqlite3_android﹕ CDF_MIN_DIGIT_MATCH = 7


Anybody know what this mean or what kind of error this is ?? And solution please. :)


Issue regarding epoch in SQLite

I've done a web application using PHP and postgres. Now, that same application I'm translating to JavaScript and SQLite. I must say, it's not been too tough and SQLite has successfully been able to interpret the same queries as I use in postgres.


Except for this one.



SELECT SUM(t.subtotal)/MAX(EXTRACT(epoch FROM (r.fecha_out - r.fecha_in))/86400) AS subtotal,
COUNT(t.id) AS habitaciones FROM reserva_habitacion t
LEFT JOIN reserva r ON t.id_reserva=r.id
WHERE (r.fecha_in <= "2015-03-27" AND r.fecha_out > "2015-03-27") AND r.estado <> 5


Using the FireFox plugin "SQLiteManager" it hints me that the error is this part epoch FROM, but I cannot get my head around it. What am I doing wrong and how could I fix it?


Any suggestions are welcome!


Appending rows to sqlite from Pandas takes non-linear time

I'm writing a large CSV (100M rows) to a sqlite database through Pandas in 10k chunks.



chunksize = 10000

for df in pd.read_csv('100M_rows.csv', chunksize=chunksize, iterator=True, encoding='utf-8'):
df.index += index_start
df.to_sql('data', disk_engine, if_exists='append')
index_start += df.index[-1] + 1


From Sqlite appending data performance linear degradation, is this solvable?, I thought that incrementing the df.index would solve this issue. However, I'm still seeing non-linear writing speeds after writing 1M rows: Non-linear write speeds from SQLite to Pandas


Is there something else that I need to do to improve the appending performance from Pandas to sqlite?


SQLite - How to delete parent row and keep the child/children rows?

I understand the concepts of PRAGMA foreign_key and of ON DELETE RESTRICT/NO ACTION, but I am facing kind of a different situation.


I need to delete a parent row but keep the child row associated with it. For example:



CREATE TABLE A(id, name);
INSERT INTO A(id, name) VALUES (1, "Loreum");

CREATE TABLE B(id, id_A, name) FOREIGN KEY(id_A) REFERENCES A(id);
INSERT INTO B(id, id_A, name) VALUES (1, 1, "Opium");
DELETE FROM A WHERE id = 1;


I want to achieve this while keeping the child row intact. Is this possible at all?


Unit Testing PHP, SQLite with Phactory

I am writing a primer on PHP Unit testing from scratch and I am looking for some simple examples of unit testing SQLite databases using http://phactory.org/. Can you point me to some references or share your ideas?


Thank you!