SQLite for PSP
SQLite for PSP
Hello all,
I port "SQLite" to the PSP by writing the OS dependent part.
This C library allow your homebrew to create database and query it with SQL langage.
If anyone interrested, ask me.
I also can upload it somewhere.
kolaaaa
I port "SQLite" to the PSP by writing the OS dependent part.
This C library allow your homebrew to create database and query it with SQL langage.
If anyone interrested, ask me.
I also can upload it somewhere.
kolaaaa
You can download it here : SQLite 3.3.17 for PSP rev. 33
README.PSP is include for building instructions.
Thanks for reporting problems (if any)
README.PSP is include for building instructions.
Thanks for reporting problems (if any)
Hi,
I will commit it as soon as I have write access to the pspdev repository.
For now, I made a patch of the same release, for those how prefers, SQLite 3.3.17 for PSP rev. 33 patch.
Use it like that :
1 - Unpack original SQLite 3.3.17 source from SQLite Site
2 - Copy the patch to the root of source
3 - in your shell : $patch -p 2 sqlite-3.3.17-psp33.patch
4 - Now you have SQLite for PSP rev. 33, see README.PSP to build the library
kolaaaa
I will commit it as soon as I have write access to the pspdev repository.
For now, I made a patch of the same release, for those how prefers, SQLite 3.3.17 for PSP rev. 33 patch.
Use it like that :
1 - Unpack original SQLite 3.3.17 source from SQLite Site
2 - Copy the patch to the root of source
3 - in your shell : $patch -p 2 sqlite-3.3.17-psp33.patch
4 - Now you have SQLite for PSP rev. 33, see README.PSP to build the library
kolaaaa
Hi! :)
I'm trying to use SQLite but I'm having problem just to open the file.
Always returns "unable to open file" error both if the file doesen't exists or if it's a SQLite db (created on PC).
What should I check?
The app is in user mode, I just included sqlite3.h, and declared sqlite3 like this:
Any idea?
Many thanks
Sakya
I'm trying to use SQLite but I'm having problem just to open the file.
Code: Select all
retValue = sqlite3_open(dbFile, &db);
What should I check?
The app is in user mode, I just included sqlite3.h, and declared sqlite3 like this:
Code: Select all
sqlite3 *db;
Many thanks
Sakya
Hi,
This code works for me :
I hope that will helps you.
kolaaaa
This code works for me :
Code: Select all
char fileName [256];
sqlite3 *db;
sprintf(fileName, "./test.db");
int rc = sqlite3_open(fileName, &db);
if( rc )
{
/* error */
}
/* success */
kolaaaa
Hi, please just an help to set up PSP SQLite, thanks in advance.
I've pspdev well set-up and running, I've donwloaded and unzipped the
- sqlite-3.3.17-psp
In the README.PSP is:
Building
--------
Make sure PSPSDK is correctly setup and PSPDEV is set.
$ LDFLAGS="-L$(psp-config --pspsdk-path)/lib -lc -lpspuser" \
./configure --host=psp --disable-readline --disable-tcl \
--prefix=$(psp-config --psp-prefix)
$ make
$ make install
Question: should I prepare a makefile with the previous instruction to building up the libsqlite3.a?
Could anyone please show me or attach a makefile ready to work with pspdev?
Then I should prepare a test database: with SQLite for Windows, from DOS promt, I run the command "sqlite3.exe test.db" and with SQL commands I could populate the test database with some structures and records. Isn't it?
Then a PSP application (ebbot.pbp) which is linking -lsqlite3 library could access the database with something like or from:
________________________
#include <stdio.h>
#include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName, argv ? argv : "NULL");
}
printf("\n");
return 0;
}
int main(int argc, char **argv){
sqlite3 *db;
char *zErrMsg = 0;
int rc;
if( argc!=3 ){
fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
exit(1);
}
rc = sqlite3_open(argv[1], &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
sqlite3_close(db);
return 0;
Isn't it ?
Thanks a lot for your help in clarifing step by step for not-enough-expert like (I'm sorry) myself.
c
I've pspdev well set-up and running, I've donwloaded and unzipped the
- sqlite-3.3.17-psp
In the README.PSP is:
Building
--------
Make sure PSPSDK is correctly setup and PSPDEV is set.
$ LDFLAGS="-L$(psp-config --pspsdk-path)/lib -lc -lpspuser" \
./configure --host=psp --disable-readline --disable-tcl \
--prefix=$(psp-config --psp-prefix)
$ make
$ make install
Question: should I prepare a makefile with the previous instruction to building up the libsqlite3.a?
Could anyone please show me or attach a makefile ready to work with pspdev?
Then I should prepare a test database: with SQLite for Windows, from DOS promt, I run the command "sqlite3.exe test.db" and with SQL commands I could populate the test database with some structures and records. Isn't it?
Then a PSP application (ebbot.pbp) which is linking -lsqlite3 library could access the database with something like or from:
________________________
#include <stdio.h>
#include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName, argv ? argv : "NULL");
}
printf("\n");
return 0;
}
int main(int argc, char **argv){
sqlite3 *db;
char *zErrMsg = 0;
int rc;
if( argc!=3 ){
fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
exit(1);
}
rc = sqlite3_open(argv[1], &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
sqlite3_close(db);
return 0;
Isn't it ?
Thanks a lot for your help in clarifing step by step for not-enough-expert like (I'm sorry) myself.
c
Thanks for your reply, kolaaaa,kolaaaa wrote:Hi,
If you want a ready to use script, see ooPo's scripts on /pspdev/psplibraries.
The library is on pspdev's repository, so you no longer need this old zip file.
For the library usage, it's that.
But, I'm sorry for that, what do you mean with "ooPo's scripts on pspdev/libraries? pspdev's repository?
somewhere on the ps3dev.org website?
something like http://svn.ps2dev.org/listing.php?repna ... rev=0&sc=0 ?
I have already downloaded all these files.
Thanks
To grab the latest version of psplibraries and install only sqlite:
Sqlite is the 16th file in the psplibraries/scripts directory. They're numbered.
Code: Select all
svn checkout svn://svn.ps2dev.org/psp/trunk/psplibraries
cd psplibraries
./libraries.sh 16
Thanks a lot, I'm downloading.ooPo wrote:To grab the latest version of psplibraries and install only sqlite:
Sqlite is the 16th file in the psplibraries/scripts directory. They're numbered.Code: Select all
svn checkout svn://svn.ps2dev.org/psp/trunk/psplibraries cd psplibraries ./libraries.sh 16
Hi to all,
thanks for help and thanks to Sakya too.
I've been able to open an existing database on PSP and select rows from tables.
I've seen open on PSP a 0-byte database file on ms0 when open a non existing database.
The PSP crashes when attempting to
CREATE TABLE (on empty database) as follows
or INSERT INTO table VALUES as follows:
Calback function is:
Thanks in advance for any help.
Is anything wrong? May be the callback?
Or PSP / SQLite3 could not work properly on Database/File IO?
my best to all
thanks for help and thanks to Sakya too.
I've been able to open an existing database on PSP and select rows from tables.
I've seen open on PSP a 0-byte database file on ms0 when open a non existing database.
The PSP crashes when attempting to
CREATE TABLE (on empty database) as follows
Code: Select all
rc = sqlite3_exec(db,"create table tbl1(one varchar(10),two smallint)",SQLite3_callback,0,&errmsg);
if (rc!=SQLITE_OK)
{
printf("Error CREATE TABLE\n");
sqlite3_free(errmsg);
}
else
{
ì printf("CREATE TABLE Exec OK \n");
}
Code: Select all
rc = sqlite3_exec(db,"insert into tbl1 values('hello',10)",SQLite3_callback,0,&errmsg);
if (rc!=SQLITE_OK)
{
printf("INSERT 10 Error \n");
sqlite3_free(errmsg);
}
else
{
printf("INSERT 10 Exec OK \n");
}
Calback function is:
Code: Select all
static SQLite3_callback(void *NotUsed, int argc, char **argv, char **azColName)
{
int i;
for(i=0; i<argc;i++)
{
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
Is anything wrong? May be the callback?
Or PSP / SQLite3 could not work properly on Database/File IO?
my best to all
Hi,
The 0-byte file is normal. You can check that on your computer without creating tables :
and a empty file is created.
But I can't find out your problem. I tried your query and it works on my PSP. Do you have print the errmsg string to know what SQLite is complaining about ?
The 0-byte file is normal. You can check that on your computer without creating tables :
Code: Select all
prompt$ sqlite3 test.db
sqlite>quit;
But I can't find out your problem. I tried your query and it works on my PSP. Do you have print the errmsg string to know what SQLite is complaining about ?
ok, it is what I was expecting: as a first step, a 0bytes file is created.kolaaaa wrote: The 0-byte file is normal. You can check that on your computer without creating tables :
PSP shows:
"Exec OK" after database/file open.
Then after sqlite3_open(...) I have in main main.c the sqlite3_exec statement for creating a table.kolaaaa wrote: But I can't find out your problem. I tried your query and it works on my PSP. Do you have print the errmsg string to know what SQLite is complaining about ?
Here the PSP doesn't show any error as expected from the test
if (rc!=SQLITE_OK)
after few seconds the PSP switch off.
If I try sqlite3_exec for insert a new record into an existing 2-records database, the same behaviour of the PSP.
No messages, no test results from
if (rc!=SQLITE_OK)
switching off.
VERY nice work, I plan on using this in my projects from now on (beats INI files by a long shot).
From what I can tell, the database is stored on the PSP. This essentially allows you to store and access data from raw files on the PSP so much easier, instead of creating a custom API or using slow/annoying INI files.JustChris wrote:Quick Q...is this an api that lets you run a database on a computer or can it work internally for the PSP so you can do admin work without the need for a computer?
So there would be no need for a server to connect to the db file? I'm not very familiar with how SQLite works but with MySQL, its API requires that you connect to a MySQL server to access a database.
I am interested in this because I was working on a program to deal with MySQL databases, but indirectly. It had a query parser for reading flat files exported by MySQL. If there is a way that I can directly access the database files instead I would gladly take that route.
I am interested in this because I was working on a program to deal with MySQL databases, but indirectly. It had a query parser for reading flat files exported by MySQL. If there is a way that I can directly access the database files instead I would gladly take that route.
That's basically how it works, I believe. It stores all the data into a .db file with no need for a server to connect to and query. Using the SQLite API, you open/query the file directly.JustChris wrote:So there would be no need for a server to connect to the db file? I'm not very familiar with how SQLite works but with MySQL, its API requires that you connect to a MySQL server to access a database.
I am interested in this because I was working on a program to deal with MySQL databases, but indirectly. It had a query parser for reading flat files exported by MySQL. If there is a way that I can directly access the database files instead I would gladly take that route.
I get a URL "this one" doesn't exist.ooPo wrote:To grab the latest version of psplibraries and install only sqlite:
Sqlite is the 16th file in the psplibraries/scripts directory. They're numbered.Code: Select all
svn checkout svn://svn.ps2dev.org/psp/trunk/psplibraries cd psplibraries ./libraries.sh 16
Is there any direct link to retrieve sqlite3.h?
If not actually, then potentially.
That's a subversion repo link. You have to use SUBVERSION to CHECKOUT the directory as the code shows ("svn" is the subversion client, "checkout" is the client command, and the "svn://..." url is the repo module to operate on).Art wrote:I get a URL "this one" doesn't exist.ooPo wrote:To grab the latest version of psplibraries and install only sqlite:
Sqlite is the 16th file in the psplibraries/scripts directory. They're numbered.Code: Select all
svn checkout svn://svn.ps2dev.org/psp/trunk/psplibraries cd psplibraries ./libraries.sh 16
Is there any direct link to retrieve sqlite3.h?
Once you checkout the psplibraries module and run the script as shown, you will have sqlite installed and ready to use.
So there is more than just SQlite3.c, SQLite3.h ?
I have never been able to run any scripts witht his install.
I only got Mikmod and Freetype from a precompiled toolchain.
At tle last line of that command cygwin tells be to install "autoconf"
before continuing, but all three versions of autoconf are already installed.
I have never been able to run any scripts witht his install.
I only got Mikmod and Freetype from a precompiled toolchain.
At tle last line of that command cygwin tells be to install "autoconf"
before continuing, but all three versions of autoconf are already installed.
If not actually, then potentially.
Uh... yes, there's a LOT more than just those two files. If all you wish to check out of the repo is sqlite, do this:
If you aren't comfortable with a command line client, there are graphical clients for Windows (I assume you're using Windows since you mention cygwin). TortoiseSVN being one.
http://tortoisesvn.tigris.org/
Code: Select all
svn checkout svn://svn.ps2dev.org/psp/trunk/sqlite
http://tortoisesvn.tigris.org/