Converting an sqlite database into format that an Android app can uses?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting an sqlite database into format that an Android app can uses?

Csányi Pál
Hi,

I am using sqlite3 on a command line, in an xterm window on Gentoo linux system.

When I am at sqlite> prompt, I enter SQL commands to create tables for
the database Probe.db which is a file on my disk.

In the Probe.db file are those SQL commands which I just entered and
naturally these line at the beginning of the file:
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;

and at the end of file:
COMMIT;


Say I want to use this database in my Android application on my phone.

How can I convert this Probe.db file into format that an Android app can uses?

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Simon Slavin-3


On 28 Aug 2017, at 5:50am, Csányi Pál <[hidden email]> wrote:

> When I am at sqlite> prompt, I enter SQL commands to create tables for
> the database Probe.db which is a file on my disk.
>
> In the Probe.db file are those SQL commands which I just entered and
> naturally these line at the beginning of the file:
> PRAGMA foreign_keys=OFF;
> BEGIN TRANSACTION;
>
> and at the end of file:
> COMMIT;

There is something wrong with this description.  You are talking about a file "Probe.db" on your disk.  But you describe two different contents for this file as if they are the same thing.

Is "Probe.db" a list of SQLite commands, stored as a text file, or a SQLite database ?  If it’s a SQLite database, can you given an example INSERT line which was used to put data into this database ?

> How can I convert this Probe.db file into format that an Android app can uses?

The SQlite database format is identical on all platforms.  You do not need to do any conversion just because you move the database from a computer to a phone.  However, your description above makes me think you have just a list of commands, not the database that these commands would make.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Csányi Pál
Hello Simon,

2017-08-28 7:14 GMT+02:00 Simon Slavin <[hidden email]>:

>
>
> On 28 Aug 2017, at 5:50am, Csányi Pál <[hidden email]> wrote:
>
>> When I am at sqlite> prompt, I enter SQL commands to create tables for
>> the database Probe.db which is a file on my disk.
>>
>> In the Probe.db file are those SQL commands which I just entered and
>> naturally these line at the beginning of the file:
>> PRAGMA foreign_keys=OFF;
>> BEGIN TRANSACTION;
>>
>> and at the end of file:
>> COMMIT;
>
> There is something wrong with this description.  You are talking about a file "Probe.db" on your disk.  But you describe two different contents for this file as if they are the same thing.
>
> Is "Probe.db" a list of SQLite commands, stored as a text file, or a SQLite database ?  If it’s a SQLite database, can you given an example INSERT line which was used to put data into this database ?

Probe.db is a list of SQL commands, stored as a text file, and not a
SQLite database.

How can I get it in SQLite database, instead of just a text file with
SQL commands?

>> How can I convert this Probe.db file into format that an Android app can uses?
>
> The SQlite database format is identical on all platforms.  You do not need to do any conversion just because you move the database from a computer to a phone.  However, your description above makes me think you have just a list of commands, not the database that these commands would make.

Understand. Just want to get the SQLite database file, but not as a
text file with SQL commands.
How can I get it?

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Simon Slavin-3


On 28 Aug 2017, at 6:25am, Csányi Pál <[hidden email]> wrote:

> Probe.db is a list of SQL commands, stored as a text file, and not a
> SQLite database.

Then please do not use a name for this file ending in ".db".  It is not a database.  It is a list of commands.  I suggest a name ending in ".txt" or ".sql".

> How can I get it in SQLite database, instead of just a text file with
> SQL commands?

You start the sqlite3.exe program using the command

sqlite3 Probe.db

Once you have the "sqlite>" prompt, type those commands one by one.  Or you can instead use the ".read Probe.txt" command to process all commands in the file.  When you are finished use the ".quit" command to exit the shell tool.

Then look on your disk for the "Probe.db" file and it will the database file.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

J Decker
is redirection so hard?

sqlite3 database.db < database.commands


On Sun, Aug 27, 2017 at 10:31 PM, Simon Slavin <[hidden email]> wrote:

>
>
> On 28 Aug 2017, at 6:25am, Csányi Pál <[hidden email]> wrote:
>
> > Probe.db is a list of SQL commands, stored as a text file, and not a
> > SQLite database.
>
> Then please do not use a name for this file ending in ".db".  It is not a
> database.  It is a list of commands.  I suggest a name ending in ".txt" or
> ".sql".
>
> > How can I get it in SQLite database, instead of just a text file with
> > SQL commands?
>
> You start the sqlite3.exe program using the command
>
> sqlite3 Probe.db
>
> Once you have the "sqlite>" prompt, type those commands one by one.  Or
> you can instead use the ".read Probe.txt" command to process all commands
> in the file.  When you are finished use the ".quit" command to exit the
> shell tool.
>
> Then look on your disk for the "Probe.db" file and it will the database
> file.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Simon Slavin-3


On 28 Aug 2017, at 7:37am, J Decker <[hidden email]> wrote:

> is redirection so hard?
>
> sqlite3 database.db < database.commands

OP is learning and testing.  If redirection doesn’t work, they don’t know what’s wrong.  The error messages in interactive mode are far clearer.

Once they have the basic thing working, they can use interactive mode.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Csányi Pál
2017-08-28 8:40 GMT+02:00 Simon Slavin <[hidden email]>:

>
>
> On 28 Aug 2017, at 7:37am, J Decker <[hidden email]> wrote:
>
>> is redirection so hard?
>>
>> sqlite3 database.db < database.commands
>
> OP is learning and testing.  If redirection doesn’t work, they don’t know what’s wrong.  The error messages in interactive mode are far clearer.
>
> Once they have the basic thing working, they can use interactive mode.

Agree.
But I did the redirection and get a Probe.db file, which is - I hope -
the database and not a text file with commands.

I attach in this mail the Probe.db file to ask you to see it, whether
is it really the database, or just a text file?

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Simon Slavin-3


On 28 Aug 2017, at 8:13am, Csányi Pál <[hidden email]> wrote:

> I attach in this mail the Probe.db file to ask you to see it, whether
> is it really the database, or just a text file?

This mailing list ignores attachments.  To see if it’s a database just try to open or type the file.  If it’s all text, it’s not a database.  If it has weird characters in it it’s probably a database.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Csányi Pál
Hello Simon,

2017-08-28 15:28 GMT+02:00 Simon Slavin <[hidden email]>:
>
> On 28 Aug 2017, at 8:13am, Csányi Pál <[hidden email]> wrote:
>
>> I attach in this mail the Probe.db file to ask you to see it, whether
>> is it really the database, or just a text file?
>
> This mailing list ignores attachments.  To see if it’s a database just try to open or type the file.  If it’s all text, it’s not a database.  If it has weird characters in it it’s probably a database.
>
> Simon.

I understand.
If I open the Probe.db to edit in Midnight Comander, then I find there
one line only, which begin like:
SQLite format 3^@^P^@^A^A^@@  ^@^@^@^B^@^@^@^C^@^@^@^ ... etc...

So it is definitely a database file and not a text file.

For newbies like me it should be mentioned this at
https://www.sqlite.org/quickstart.html
bellow the 'Create A New Database' title,
and below the line:
Enter SQL commands at the prompt to create and populate the new database.

like:

When one finished entering SQL commands and used the ".quit" command
to exit the shell tool, then there will be not a text, but a database
file which can then be used on various devices, like smart phones,
etc.

No?

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Richard Hipp-3
On 8/28/17, Csányi Pál <[hidden email]> wrote:
>
> When one finished entering SQL commands and used the ".quit" command
> to exit the shell tool, then there will be not a text, but a database
> file which can then be used on various devices, like smart phones,
> etc.
>

correct

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that an Android app can uses?

Simon Slavin-3
In reply to this post by Csányi Pál


On 28 Aug 2017, at 2:50pm, Csányi Pál <[hidden email]> wrote:

> If I open the Probe.db to edit in Midnight Comander, then I find there
> one line only, which begin like:
> SQLite format 3^@^P^@^A^A^@@  ^@^@^@^B^@^@^@^C^@^@^@^ ... etc...
>
> So it is definitely a database file and not a text file.

You are correct.  You now have a database file.

> For newbies like me it should be mentioned

Actually I can’t remember us having this problem posted before.  If someone else comes up with the same problem the documentation should be changed.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
ajm
Reply | Threaded
Open this post in threaded view
|

Re: Converting an sqlite database into format that anAndroid app can uses?

ajm
In reply to this post by Csányi Pál

> ---- Mensaje original ----
> De: Csányi Pál <[hidden email]>
> Para:  SQLite mailing list <[hidden email]>
> Fecha:  Mon, 28 Aug 2017 15:50:13 +0200
> Asunto:  Re: [sqlite] Converting an sqlite database into format that anAndroid app can uses?
>

>I understand.
>If I open the Probe.db to edit in Midnight Comander, then I find there
>one line only, which begin like:
>SQLite format 3^@^P^@^A^A^@@  ^@^@^@^B^@^@^@^C^@^@^@^ .. etc...
>
>So it is definitely a database file and not a text file.
>
>For newbies like me it should be mentioned this at
>https://www.sqlite.org/quickstart.html
>bellow the 'Create A New Database' title,
>and below the line:
>Enter SQL commands at the prompt to create and populate the new database.
>
>like:
>
>When one finished entering SQL commands and used the ".quit" command
>to exit the shell tool, then there will be not a text, but a database
>file which can then be used on various devices, like smart phones,
>etc.
>
>No?

It seem obvious even to newbies as your that after created the very first database, the next step would be try some commands against the new file to see how it behaves. I.E. .tables, .schema, .dbinfo, .dump, .show or whatever. If the response is some Ok. then the thing is a database and well formed.

H.T.H.

--
Adolfo J. Millan

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users