Hi there,
I tried to find something in the forum but without success. So here my question:
How can I save a database which I created in memory?
Any ideas or ready made solutions?
save :memory: SQLite database to database file on HDD
- menschmarkus
- User
- Posts: 18
- Joined: Fri Dec 28, 2012 11:23 pm
- Location: Center Germany
save :memory: SQLite database to database file on HDD
As soon you do it right, it works !
Re: save :memory: SQLite database to database file on HDD
viewtopic.php?p=363718#p363718menschmarkus wrote:Any ideas or ready made solutions?
Greetings ... Peter
Hygge
- menschmarkus
- User
- Posts: 18
- Joined: Fri Dec 28, 2012 11:23 pm
- Location: Center Germany
Re: save :memory: SQLite database to database file on HDD
Perfect, thank you kiffi
Edit:
Hm, I tried out your code.
At the command line:
Code: Select all
BackUp = sqlite3_backup_init(DatabaseID(DbFile), "main", DatabaseID(DbMem), "main")
Code: Select all
If BackUp
Code: Select all
Debug sqlite3_errcode(DatabaseID(DbFile))
I add another debug line
Code: Select all
Debug sqlite3_errcode(DatabaseID(DbMem))
The "temp.db" file exists. Size is 0
I don't want to say your code is wrong but something else seems to be wrong.
For your information I use PB 5.71 LTS in 32 bit with Win10 64 bit OS.
Any idea what may happened?
Edit2:
I tried PB 5.46 LTS. Here it works fine. It seems something in PB 5,71 LTS has changed.
As soon you do it right, it works !
Re: save :memory: SQLite database to database file on HDD
May be it's an unicode issue, you can try to change the import to:
sqlite3_backup_init(pDest, zDestName.p-utf8, pSource, zSourceName.p-utf8)
sqlite3_backup_init(pDest, zDestName.p-utf8, pSource, zSourceName.p-utf8)
- menschmarkus
- User
- Posts: 18
- Joined: Fri Dec 28, 2012 11:23 pm
- Location: Center Germany
Re: save :memory: SQLite database to database file on HDD
I am sorry for bothering you but
I still get Error Code 1 for FileDB
Furthermore I proviously checked valid opened FileDB with right after opening the empty file as Database. This gives a valid value.
Used Hardware/Software:
Win 10 (1909)
PB 5.71 LTS (x86)
Is it really a bug?
I changed Kiffis original code to:Fred wrote:May be it's an unicode issue, you can try to change the import to:
sqlite3_backup_init(pDest, zDestName.p-utf8, pSource, zSourceName.p-utf8)
Code: Select all
... BackUp = sqlite3_backup_init(DatabaseID(DbFile), "main.p-utf8", DatabaseID(DbMem), "main.p-utf8") ...
Furthermore I proviously checked valid opened FileDB with
Code: Select all
Debug IsDatabase(DbFile)
Used Hardware/Software:
Win 10 (1909)
PB 5.71 LTS (x86)
Is it really a bug?
As soon you do it right, it works !
Re: save :memory: SQLite database to database file on HDD
Add the .p-utf8 extension to the declaration, and not the call:menschmarkus wrote:...I changed Kiffis original code to:Code: Select all
... BackUp = sqlite3_backup_init(DatabaseID(DbFile), "main.p-utf8", DatabaseID(DbMem), "main.p-utf8") ...
Code: Select all
ImportC "sqlite3.lib"
sqlite3_backup_init(pDest, zDestName.p-utf8, pSource, zSourceName.p-utf8) ;<-- add the extensions here
sqlite3_backup_step(sqlite3_backup, nPage)
sqlite3_backup_finish(sqlite3_backup)
sqlite3_errcode(db)
EndImport
Code: Select all
BackUp = sqlite3_backup_init(DatabaseID(DbFile), "main", DatabaseID(DbMem), "main")
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
- menschmarkus
- User
- Posts: 18
- Joined: Fri Dec 28, 2012 11:23 pm
- Location: Center Germany
Re: save :memory: SQLite database to database file on HDD
OMG, did not see the wood for the treesTI-994A wrote: Add the .p-utf8 extension to the declaration, and not the call:
Thanks TI-994A
As soon you do it right, it works !