An external library or mini-language for reading database schema?

I am considering writing a simple application for my wife, but I am well versed in programming practice and want to have a user-friendly source for storing the database schema.

Only, I don’t know any tools for work, and I can’t believe that they don’t exist --- maybe I just don’t know what to ask Google, but I don’t find them.

So, what libraries or other tools out there support a scheme for reading a database from text files.


Invenetix task: I expect to generate the database creation code at build time or to include the schema description in the release and build the database from the description at run time. Draemon’s suggestion would be nice, but I don’t want to be locked into predefined DBMSs if I can help him.

Perhaps I should say that I used to use databases in programming projects, but I was never responsible for the creation code.

Maybe I'm over an engineering problem at the moment.

+2
source share
5 answers

Just use SQL. SQL is not only a query language, but also DDL (data definition language). If, for example, you use mysql; you can design your schema however you want, run mysqldump, which will create an SQL file with DDL statements. Remove the schema, then you can load the schema at any time convenient for you using the SQL file. Personally, I just write the SQL schema in a text editor and load it into mysql.

This will work for mysql, postgresql, oracle and possibly for any other database.

+4
source

I think now I understand a little better.

Despite the fact that every SQL solution on the market must adhere to a certain level of compliance with ANSI SQL standards, all of them will provide some kind of user-defined data type that cannot be publicly / used / recognized in another SQL server solution.

As in MySQL 4, you will have enough choices to use (DATE, DATETIME, TIME, YEAR and TIMESTAMP), while in MS SQL 2000 you will only have a couple (DATETIME or SMALLDATETIME). You must make sure that any circuitry that you ultimately generate is common to the solutions you are willing to support.

MySQL Data Types

MS SQL 2000 Data Types

Does it help?

+1
source

SQLite does not save its data in text format, but is likely to do what you like.

It is ideal for an embedded database - no servers, no settings, and the database is in a single file that can be managed by your application.

http://www.sqlite.org/

+1
source

You can check out http://www.codesmithtools.com/ . The tool is designed to read database schemas and allows you to create code templates based on this schema. It has an abstract library for accessing schema data.

+1
source

I still can not give comments, but if I understood it correctly, do you want the application or library to build the scheme depending on the data provided in the text file?

Could you provide an approximate workflow in which you want to execute? At what stage did you encounter the problem?

0
source

All Articles