Installation
pip install noseapp_alchemy
Install extension from app
config module
from noseapp.ext.alchemy.mysql_ex import make_config
MY_DB = make_config()
MY_DB.configure(
host='127.0.0.1',
port=3306,
user='root',
password='',
db='target',
protocol='mysql',
# pool_size=POOL_SIZE,
# pool_class=POOL_CLASS,
# strategy=ENGINE_STRATEGY,
# max_overflow=MAX_OVERFLOW,
# bind_key=DB_BIND_KEY,
)
ALCHEMY_EX_MYSQL = (
MY_DB,
)
ALCHEMY_EX_SESSION = {}
etc...
app module
from noseapp import NoseApp
from noseapp.ext.alchemy import MySQLEx
class MyApp(NoseApp):
def initialize(self):
MySQLEx.install(self)
suite
from noseapp import Suite
from noseapp import TestCase
suite = Suite(__name__, require=['mysql'])
class MyTestCase(TestCase):
def setUp(self):
self.db = self.mysql.get_client()
# get by bind key
self.db = self.mysql.get_client('bind key')
def test(self):
with self.db.read() as execute:
result = execute('SELECT 1').fetchone()
self.assertTrue(result)
Usage ORM
from sqlalchemy import Column
from sqlalchemy import String
from sqlalchemy import Integer
from noseapp.ext.alchemy.orm import BaseModel
class MyModel(BaseModel):
class Meta:
# bind = 'bind key from db settings'
table = 'table name'
id = Column(Integer, autoincrement=True, nullable=False, primary_key=True)
name = Column(String(255), nullable=False, default='Name')
Create new object
obj = MyModel.create(name='Hello World!')
Update object
obj = MyModel.objects.get(1) obj.update(name='Hello!')
Get objects by
objects = MyModel.objects.getlist_by(name='Hello') obj = MyModel.objects.get_by(name='Hello')
Etc…See orm module…
Metadata
Release files for noseapp_alchemy 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| noseapp_alchemy-1.0.0.tar.gz | 4.3 kB | Without provenance | Details |
Release files / noseapp_alchemy-1.0.0.tar.gz
| Download URL | noseapp_alchemy-1.0.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0afd857bddb558249cb81599efad0b6570e9f2c9dc75ab652c58abfccd78f57b
|
|
BLAKE2b-256 checksum How to use checksums |
7d49da600907c685890bb9f5407b82e856a29a10cabcc5c1a9526b98797dab3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for noseapp_alchemy 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.