Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyzima-spb/pony-database-facade
https://github.com/kyzima-spb/pony-database-facade
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kyzima-spb/pony-database-facade
- Owner: kyzima-spb
- License: apache-2.0
- Created: 2017-11-02T17:16:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-19T19:18:03.000Z (almost 7 years ago)
- Last Synced: 2024-10-28T23:12:14.798Z (about 2 months ago)
- Language: Python
- Size: 28.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Pony Database Facade
====================|PyPI| |LICENCE| |STARS|
PonyORM Database object Facade. The package encapsulates the names of the parameters used in the low-level modules.
`Русская документация`_
Installation
------------::
pip install pony-database-facade
Constructor
-----------The ``DatabaseFacade`` constructor and the ``bind`` method takes the following arguments:
provider
The name of the database provider.
One of the list: ``sqlite``, ``mysql``, ``postgres`` or ``oracle``.
By default is ``sqlite``.dbname
The name of the database.
If you are using SQLite, the name of the file in which SQLite will store the data and by default is ``:memory:``.host
Name of host to connect to.
By default is ``localhost``.port
TCP port of database server.
By default is standard port.user
User to authenticate as.
By default is ``None``.password
Password to authenticate with.
By default is ``None``.charset (MySQL only)
By default is ``utf8``.create_db (SQLite only)
Try to create the database if such filename doesn’t exists.
By default is ``True``.\*args
parameters required by the database driver.\*\*kwargs
parameters required by the database driver... code:: python
# SQLite in memory
db = DatabaseFacade()# MySQL, localhost, no user, no password, used database blog
db = DatabaseFacade('mysql', dbname='blog')
db = DatabaseFacade(provider='mysql', dbname='blog')# PostgreSQL
db = DatabaseFacade()
db.bind('postgres',
host='my.vps.com',
user='anyone',
password='anykey',
dbname='blog')Connection
----------To connect to the database, use the ``connect`` method.
This method takes the same arguments as `generate_mapping`_, but the default for ``create_tables`` is ``True``.
This method also calls the ``bind`` method... code:: python
db = DatabaseFacade()
db.connect()Full example
------------.. code:: python
from pony.orm import Required, db_session, show
from pony_database_facade import DatabaseFacadedb = DatabaseFacade()
class Person(db.Entity):
username = Required(str, 50)db.connect()
with db_session:
person_1 = Person(username='Linus')show(person_1)
.. |PyPI| image:: https://img.shields.io/pypi/v/pony-database-facade.svg
:target: https://pypi.python.org/pypi/pony-database-facade/
:alt: Latest Version.. |LICENCE| image:: https://img.shields.io/github/license/kyzima-spb/pony-database-facade.svg
:target: https://github.com/kyzima-spb/pony-database-facade/blob/master/LICENSE
:alt: Apache 2.0.. |STARS| image:: https://img.shields.io/github/stars/kyzima-spb/pony-database-facade.svg
:target: https://github.com/kyzima-spb/pony-database-facade/stargazers.. _Русская документация: docs/RU.rst
.. _generate_mapping: https://docs.ponyorm.com/api_reference.html#Database.generate_mapping