Creating a RDF in Jython - database

How do we create RDF database in Jython? I use this to implement SparQL in Jython. So I need to create the database first.

See RDFAlchemyJython for reusing most well known Java tools for RDF and SPARQL in Jython; or go for RDFLIB, a wide spread RDF and SPARQL framework for Python.

I was going to say use the Jena libs, but msalvadores got there already, check the RDFAlchemyJython link. I'll add that it is pretty straightforward, just use them like you would any other Java libs in Jython.
TDB is probably the best bet for a SPARQLable database, see:
https://jena.apache.org/documentation/tdb/java_api.html
Just put the libs on your classpath, tweak the code to be js not Java.

Related

node.js some questions about store data

I am trying to understand how node.js works.
1) I would like to store data, but I don't know which method is the faster:
-using sql
-using json files (if this is a good solution have you got a tutorial for best practice)
2) A multilang website, is it a good solution to store translations in json files or is there a best practice?
Handling JSON is faster with JavaScript than SQL because it's native so I would always use JSON over any other data format with node.js wherever possible. In terms of storing JSON, you can go for NoSql solution eg: MongoDB or CouchDB.
This link will get you started on MongoDB.
There are many options for multilingual websites, you can use Google translate or tons of other plugins depending on your requirements. If you want to store literal translations then NoSql DB will work fine. In terms of best practices, refer to this question.
For Translation, you should ideally use internationalization module, whatever language or framework it is. In Node.JS you have i18n-node for internationalization. Your translation will be stored in JSON files. There are also other modules which can store your traslations in db.

Do you know a database written in Perl with DBI interface?

Do you know a database written purely in Perl with DBI interface?
Or what can be used if there is no MySql or Postgresql installed and I want to use Perl only?
Thank you.
Ok, I just wanted something that can be used with Catalyst.
What about SQLite? DBD::SQLite
I believe DBD::CSV is a simple DBD implementation that uses Text::CSV to persist data to CSV files.
That depends greatly on what you consider "database".
If you just want something to store your data, there's a number of Perl databases avialable. Some are listed here: http://www.perl.com/pub/a/2004/09/12/embedded.html
Tie::File
Berkley DB
SQLite
Please note that despite "SQLite is written in C" comments I saw here, the article explicitly states:
Conveniently, the DBI-driver for
SQLite, DBD::SQLite, already contains
the database engine itself as part of
the module - so installing this module
is all that is required to be able to
use SQLite from Perl.
However, NONE of the above is a real database engine, supporting transactions etc..., although some allow SQL-like query language access
I'm not aware of any real database engines implemented in Perl.
Perl rule 34:
If you can imagine it, there's a DBD
module for it ;)
http://search.cpan.org/search?m=module&q=DBD::&s=1
AFAIK there is no database in pure perl that is relational, it's not really economical; you might look in ACME on CPAN.
Essentially you have two choices: a pure perl module that provides a DBD package that wraps around, for example .txt, .csv, or .xml files.
If there is none, you could also implement a BDB/DBM style system of your own using pure perl, much like Ken Thompson did in C with DBM. It however, wouldn't be as complex as having SQL based relational database.
If you expect to use SQL, use an SQL based database.
DBD::DBM is a pure Perl database driver which is part of DBI itself since version 1.42 (April 2004). It can work with a variety of different database formats using the respective modules, e.g. BerkleyDB or SDBM_File (core module).
One needs to combine this with MLDBM to get a usable database (otherwise ony two columns per table are supported).
The documentation of DBD::DBM is quite extensive and provides a good overview of the different options and how to set it up.

Language/Framework support for Interacting With CouchDB

I am interested in knowing if there are any server-side web application frameworks which integrate nicely with CouchDB? Does anyone have any experience in doing this? It seems like a dynamic language would be well-suited for playing with the JSON, but I am more interested in hearing about how it would fit in with the framework and the application's design.
Two frameworks that I would suggest for CouchDB are Ruby on Rails and Django. Both have a small file you can include that allows for easy interaction with CouchDB. For Ruby/Rails, this gives you the ability to write code that looks like this (code snippets yanked from here):
# Create the database
server = Couch::Server.new("localhost", "5984")
server.put("/foo/", "")
# Insert a new document into the database
doc = <<-JSON
{"type":"comment","body":"First Post!"}
JSON
server.put("/foo/document_id", doc)
# Get the document back later
res = server.get("/foo/document_id")
json = res.body
puts json
Python/Django lets you do the same with a relatively minimal amount of work (see here). Both of these aren't at the web framework level but they require a minimal amount of work to set up and are pretty easy to get going in Rails and Django. The Django approach still requires some packages to be installed so if you just can't do that for some reason the Rails approach is the way to go.
Another good how-to on Python on Django can be found here (also lifted from the CouchDB FAQ).
The only web framework that dedicates itself to CouchDB is currently CouchDBKit for Python.
Check out the official wiki page that lists how to get started in your language:
http://wiki.apache.org/couchdb/Basics
Pick the language and framework that suits you best and then use one of the light CouchDB libraries with it.
It seems that things are move quite quickly at the moment for CouchDB. I'm sure there will be more frameworks out there soon with CouchDB support. I'm currently looking into building one for PHP.
I have had good success with jcouchdb for Java and CouchApp for JavaScript and CouchDBKit with Python. All of these are actively developed, open source and well designed and easy to enhance if they are missing something you really need. I have submitted patches and feature enhancements for jcouchdb and couchapp both.
Actually, you don't really need such a framework. Instead, you can just write the whole web application in CouchDB. It allows you to generate HTML files, or any other XML derived format, and you can even use HTML-templates. I consider this a good choice, because JavaScript is a rich and flexible language. On the other hand you don't have the overkill of a connection between the database and your web application.
For more details, check out: http://books.couchdb.org/relax/design-documents/shows
There's also a related question: Using CouchDB to serve HTML
Depending on what you want to build CouchApp may be something to look at: It's specially designed for writing apps with CouchDB:
https://github.com/jchris/couchapp/wiki/manual

Is there a Perl ORM with database reverse engineering?

I’m looking for a Perl ORM library that has support for reverse engineering of the database schema. All I’ve found so far is
http://perlorm.sourceforge.net/
and it appears to have no reverse engineering support.
There is a list of recommended ORM modules at the P5P wiki.
Rose::DB::Object and DBIx::Class can generate classes for you from an existing database schema, and can also write them out to a set of Perl module files.
Rose::DB::Object::Loader
DBIx::Class::Schema::Loader
DBIx::Class has DBIx::Class::Schema::Loader which generates classes for you from an existing datbase and can also write them out to files. It it limited to loading a single schema though.
There are three commonly used ORMs in Perl, Class:DBI, DBIx::Class and Rose::DB::Object. According to this page at PerlMonks, they can all load the metadata from the database, but it doesn't say how.

Laravel 5 Writing Custom Database Driver

I'm working on project and need to implement custom database driver, but can't find any guidelines which interfaces i should to implement.
Is there any resourses available that could help writing custom driver rather thank just diving in code and trying to figure out how current drivers are implemented?
EDIT
By saying "driver" i mean support for example NoSQL dabase using standart Laravel's methods ( Eloquent model and Query builder ), for example:
User::take(10)->get();
For Mysql Laravel uses eloquent
laravel - eloquent
For NoSql like MongoDB, you can use laravel-mongodb
jenssegers - laravel-mongodb
It's even support Hybrid relations between MySql and MongoDB
I have worked on MongoDB (a NoSQL database) in one of my project, where I have to use a jenssengers package https://github.com/jenssegers/laravel-mongodb to use the functionalities. I was not able to use Eloquent in that.
Laravel - eloquent/ jenssegers - Laravel-MongoDB can manage hybrid relations as well.

Resources