Não é mais possível fazer postagens ou usar assinaturas novas da Usenet nos Grupos do Google. O conteúdo histórico continua disponível.
Dismiss

mozStorage documentation up

105 visualizações
Pular para a primeira mensagem não lida

Brett Wilson

não lida,
4 de mai. de 2006, 11:28:4904/05/2006
para
http://developer.mozilla.org/en/docs/Storage

Please let me know if there is a part that you can't figure out.

Brett

Dan Mosedale

não lida,
4 de mai. de 2006, 18:30:2404/05/2006
para Brett Wilson
Brett Wilson wrote:
> http://developer.mozilla.org/en/docs/Storage
>
> Please let me know if there is a part that you can't figure out.

Can you post this to m.d.platform also?

Thanks,
Dan

Casperion

não lida,
8 de mai. de 2006, 00:34:5808/05/2006
para
Is there a method attached to mozstorage to retreive jsut the column
names of a sqlite db?

Brett Wilson

não lida,
8 de mai. de 2006, 12:00:5108/05/2006
para
Casperion wrote:
> Is there a method attached to mozstorage to retreive jsut the column
> names of a sqlite db?

You can get this information from the built-in sqlite_master table:
http://www.sqlite.org/faq.html#q9
You might have to parse the results, though.

Brett

Casperion

não lida,
8 de mai. de 2006, 20:34:1708/05/2006
para
Yeah I know about the master table, but to put it bluntly, its a pain
to impliment :(

It would be seriously cool if you were able to pull the column names by
calling a method or function attached to the mozstorage API =D

That brings me to another query, can you access a remote (ie. from
another website/server) sqlite db file using mozstorage?

Brett Wilson

não lida,
8 de mai. de 2006, 21:44:5808/05/2006
para
Casperion wrote:
> Yeah I know about the master table, but to put it bluntly, its a pain
> to impliment :(

I understand it would be useful. My excuse is that you should know your
own database schema. My real reason is that I don't want to write it
because it's a pain to implement :)

> That brings me to another query, can you access a remote (ie. from
> another website/server) sqlite db file using mozstorage?

No. I guess we could get this to work in read-only mode, but basically
it would involve downloading the DB to the local drive and opening it.
If you want that, you can do it yourself.

Brett

Eric Desbiens

não lida,
9 de mai. de 2006, 11:59:2909/05/2006
para
Hi Brett,

The docs are welcome and reallly well done. I have been using
mozStorage for a month now and I learn a few usefull things from your doc.

The only thing missing from the doc is a part on
mozIStorageStatementWrapper which in my opinion make code more readable
since you can access colums by their name and not their index.

Keep up the good work!
Eric

Brett Wilson

não lida,
9 de mai. de 2006, 13:05:2009/05/2006
para
Eric Desbiens wrote:
> The only thing missing from the doc is a part on
> mozIStorageStatementWrapper which in my opinion make code more readable
> since you can access colums by their name and not their index.

Hey, cool. I never noticed that! I'll figure out how to use it sometime
and document it.

Brett

Casperion

não lida,
9 de mai. de 2006, 20:59:0409/05/2006
para
you can do it by:

var nAr = new Array();
while(wrapper.step())
{
nAr.push(wrapper.row["columnname"]);
}

alert(nAr.join("\n");

Casperion

não lida,
9 de mai. de 2006, 21:01:0609/05/2006
para
ANother thing I wanted to ask, the mozstorage extension, it gives me
invalid file format with some sqlite db's I use?

Is there a particular method to create a db that the mozstorage
extension will accept (as I dont want to have to make copies of the
calender one to have to make it work...)

Any ideas?

Brett Wilson

não lida,
10 de mai. de 2006, 11:46:0710/05/2006
para

I think you're probably using different versions of sqlite.

Brett

Casperion

não lida,
10 de mai. de 2006, 21:22:3610/05/2006
para
yep I just figured it out :(
Thanks for your help.

Sébastien Philippon

não lida,
29 de nov. de 2006, 07:38:1929/11/2006
para
Brett Wilson a écrit :

> http://developer.mozilla.org/en/docs/Storage
>
> Please let me know if there is a part that you can't figure out.
>
> Brett

There is something unclear to me. Does the openDatabase method create
the database file if it does not exist or do I have to create it
manually beforehand? In that case, is it enough to just create an empty
file using the nsIFile.create method and then open a database connection
on that file to execute some CREATE TABLE statements, or do I have to
create the database file using the sqllite command line client? Thanks
in advance.

Adam Kowalczyk

não lida,
29 de nov. de 2006, 09:09:5829/11/2006
para
Sébastien Philippon wrote:
> There is something unclear to me. Does the openDatabase method create
> the database file if it does not exist or do I have to create it
> manually beforehand? In that case, is it enough to just create an empty
> file using the nsIFile.create method and then open a database connection
> on that file to execute some CREATE TABLE statements, or do I have to
> create the database file using the sqllite command line client? Thanks
> in advance.

openDatabase creates the file if it doesn't exist yet, so you don't have
to create it first.

Here's an example that creates an new database in the profile directory
or opens an existing one:


var file = Cc['@mozilla.org/file/directory_service;1']
.getService(Ci.nsIProperties)
.get('ProfD', Ci.nsIFile);
file.append('database.sqlite');

var storageService = Cc['@mozilla.org/storage/service;1']
.getService(Ci.mozIStorageService);
var dBConnection = storageService.openDatabase(file);


- Adam

Sébastien Philippon

não lida,
29 de nov. de 2006, 11:01:0629/11/2006
para
Adam Kowalczyk a écrit :

> openDatabase creates the file if it doesn't exist yet, so you don't have
> to create it first.

Thanks, I managed to find that out by myself (actually I was too lazy to
test it, but I did it anyway :p).

Still I have another question (and for this one I don't see how to test
it): is it possible to execute statements from a .sql script file? This
could be useful to create the tables and to insert initial data. Well I
believe it is possible, my problem is more about accessing to the
content of such a file. Suppose my .sql scripts are stored under the
"sqlfiles" folder which is placed at the root of the directory structure
of my extension. Can I access my files via a chrome:// url, or is there
another way to achieve this?

Adam Kowalczyk

não lida,
29 de nov. de 2006, 12:15:5529/11/2006
para
Sébastien Philippon wrote:
> Still I have another question (and for this one I don't see how to test
> it): is it possible to execute statements from a .sql script file? This
> could be useful to create the tables and to insert initial data. Well I

Why do you want a separate file for these statements instead of
hardcoding them in JS?

> believe it is possible, my problem is more about accessing to the
> content of such a file. Suppose my .sql scripts are stored under the
> "sqlfiles" folder which is placed at the root of the directory structure
> of my extension. Can I access my files via a chrome:// url, or is there
> another way to achieve this?

Yes. You should put them in \chrome\content, though.

We're going off-topic, so I guess it'd be better to continue this on
m.d.extensions.

- Adam

0 nova mensagem