ORM tool to create SQL tables - sql

I need to create a database in SQLite, but I do not want to create the tables manually.
I already have the model of the data I need in the database, and what kind of relationship is each one (many-many, one-many, ...)
I'm wondering if there is a tool that allows me to do that?
I just need the tool to generate the SQL code. Then I will take care of the queries manually using SQL
I was thinking about placing the model in Django, and see what it generates, but there should be a tool not linked to a particular language that allows me to do that. Am I wrong?

Hibernate have the ability to create a scheme from mapped classes. There is support for SQLite.

You can go for dia (see "Tools that generates something from Dia diagrams" at http://projects.gnome.org/dia/links.html).
Also there is SQL::Translator and DBIx::* that allows reading an schema from YAML, Excel, and other sources, but these are Perl specific.
Good luck

You can use Symfony + Doctrine framework. It can generate SQL queries.

Try this module on CPAN: Parse::Dia::SQL

Related

PostgreSQL equivalent to MongoDB's Mongoose?

I'm using PostgreSQL for a project , and for that I need a SQL database.
Anyone knows what's PostgreSQL equivalent to MongoDB's Mongoose ?
It depends on what you are coding in. Mongoose is an ODM or object data modelling tool for Node.js.
Those object modelling tools are typically tied to a particular language or framework. In Java, one might use Hibernate. In Django, there is a custom ORM (swap data for relational). With Node, one might use a tool like Sequalize.
Sequalize is probably the answer you are looking for.
you can try Sequelize for PostgreSQL
If you are looking for a way to convert JSONB typed columns into objects that you can load update and save like you do using mongoose:
The ยง "JSONB (PostgreSQL only)" type in the sequelize documentation will show you how.
node-postgres might be an alternative

Is there a way to reverse engineer an existing schema into Liquibase?

We have an existing schema created the old fashioned way with raw SQL. I'd like to reverse engineer in to Liquibase change set. Is there any easy way to do that?
Regards,
Prakash
Yes, there is. This is documented in the Liquibase documentation "Starting Liquibase on an existing project"
You want to use the 'make it look like you've always used Liquibase' method, which basically involves using the generateChangeLog command. Note that there may be things in your database that Liquibase does not fully support, depending on your database platform. If you discover that there are many things like that, you may want to look into Datical DB, a commercial offering that uses Liquibase as its core engine, but which extends it quite a bit. I am one of the lead developers on that product.

Is there an existing piece of software that allows you to (easily) build queries throught a webpage?

I would like to build arbitrary queries to a database, by allowing the user to build queries "on the fly". For every object/table, being able to select its attributes, and then "building" the query (that would translate into a SQL statement) and finally launching it, all through a web interface.
The ticketing system "rt" does that, for example, and another example would be the http://gatherer.wizards.com/Pages/Advanced.aspx webpage.
I'm currently programming in rails but any existing solution that implements this (or something similar) would be welcome.
Just be careful when creating dynamically generated queries like this that will need to be executed via sp_executesql (example: ms sql server), etc..... make sure you cover all of your bases to ensure that your application isnt vulnerable to SQL injection attacks as this type of development will essentially get one in a lot of trouble if its done incorrectly.. I would recommend storing all queries in a table and only reading queries from this table to help isolate the queries that are being ran in your application. Just identify them with a label, and allow the EU to choose the label from a dropdown list control on the frontend.
Good luck and I'm not sure of any software that will help assist
Not quite sure what your use case is here but i would say check out the
Doctrine ORM ( Object Relational Mapper )
**Edit
After reading more and looking at the example. I would only suggest Doctrine for a large website.
Then use Doctrines DQL syntax with some javascript/jquery magic for the forms.
Note that the queries you're referencing aren't arbitrary: they're on a very specific problem domain, on a specific set of sql tables.
That said, if I were you I'd look into how people are building sql queries with javascript. Something like these:
http://code.google.com/p/django-querybuilder/
http://css.dzone.com/articles/sqlike-sql-querying-engine?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+zones%2Fria+(RIA+Zone)
http://thechangelog.com/post/4914956307/rel-arel-ported-to-node-js-with-some-changes
That'll at least get you a good idea of the underlying data structures.

How to maintain SQL scripts when developing an application working against many databases

Imagine an application which is supposed to work with different database vendors. As we all know the syntax for SQLs (especially DDL) is not portable. How do you deal with maintaing the SQL scripts?
Until now I see three options:
to store SQLs in format of one of the databases and have a tool which automatically converts from one syntax do another (do you know such tools?)
to store SQLs in some artificial language and a have a tool which is able to generate vendor-specific SQLs on demand (any recommendation here?)
to store SQLs in many database formats neglecting the redundancy (this is the worst one, isn't it?)
Do you recommend any of them? Do you have a better idea?
The development environment tries to follow the continuous integration principles, so automation is a key feature here.
Have a look at Liquibase (that's essentially your second item on the list)
http://www.liquibase.org
It's not perfect (e.g. it does not support check constraints) but it is quite useful
This video shows a solution using the Subsonic project http://subsonicproject.com/docs/Using_SimpleRepository and its data migration capabilities. The strategy is to use a general language and apply it to different databases.
Hope this is what you were looking for
Use some kind of ORM framework with schema generation capability.

What to use for a flexible data access layer - OLEDB or...?

I am creating a quick and dirty prototype (C#) of an object-relational mapping tool. I would like to support at least two kinds of databases - one will be Microsoft SQL Server 2005/2008 and the other most probably MySQL.
Is there any way to use a single data base access mechanism for both database engines and what would it be?
Of course, I know that there will be differences in SQL query syntax, but in my case it is not that important - I'll use a tool to generate SQL queries which suit the certain db engine and user will be able to optimize those SQL queries.
The main idea is to have as flexible data provider solution as possible. Can it be done or not and how can it be done easier?
Note that I am not using this for a production system, just for a prototype, but still I'm curious how it is achieved in production OR/M tools - are they using completely separate access mechanism for each data provider or there are something common? And are they using DataReaders or there is some more appropriate way to retrieve data if I intend to transform data to business objects?
Thanks for any ideas, links etc.
Ok, I found it:
http://www.15seconds.com/issue/040127.htm
the solution is to use IDbxxx or Dbxxx as described in msdn.microsoft.com/en-us/library/ms379620(VS.80).aspx
Now I can specify only once what kind of DataProvider I use and then just use Db/IDb everywhere else.
I recommend nhibernate - which does what you want I think.
nhibernate.info