GnrSql Overview
The GenroSql library is the main tool that genropy project uses to handle database in Python. We decided to make it available as an independent package. At this time there are 2 db adapters: one for PostgresSQL one for sqlite. We hope that soon will be avaliable adpaters for Firebird, Mysql and other Dbms.
GnrSqlDb
Is the core class of GenroSql. GnrSqlDb performs these assignments:
- handling dbms
- accessing the database
- managing and exporting data
- others
Database model
GnrSqlDb has a Model which represents the database structure. The Model contains a recipe of the database called Source and a hierarchy of objects that handle all db elements (tables, columns etc.).
You can import the model from an existig db or define it importing an XML file or using some python easy functional call.
Accessing the db
GnrSqlDb has a particular way to do query. In fact we can say that a query in our sql handler starts from the point of view of a single table (the same of the SQL statement FROM).
So in the query method of Table you can select columns belong to the table instance itself but also all the columns of the tables related to the starting table through an automatic join management.
The method query return the stored query as a new SqlQuery? instance
Getting data
A way to manage the extracted data is the SqlSelection? object. An SqlSelection? instance is created by the selection() method of SqlQuery?. You can sort, filter, store export the data into SqlSelection?. You can export the data into differents format through output SqlSelection? method.
You can also get fetch, cursor, servercursor etc. directly from SqlQuery?.
Attachments
- SqlTableQuery.jpg (26.6 kB) - added by fporcari 12 months ago.
