Table des matières
- 2026:
- 2025:
6 billet(s) pour juillet 2026
| Contre DNS | 2026/07/28 09:29 | Jean-Baptiste |
| Limiter la consommation de la RAM d'une application avec les cgroups slices | 2026/07/28 05:29 | Jean-Baptiste |
| Procédure simple augmentation de la SWAP | 2026/07/17 15:49 | Jean-Baptiste |
| Exemple git clone avec Ansible | 2026/07/16 14:47 | Jean-Baptiste |
| Windows exe - Comparaison de fichiers binaires | 2026/07/16 10:25 | Jean-Baptiste |
| Pb git | 2026/07/01 17:36 | Jean-Baptiste |
Notes Python DB - ORM - DAL
Voir :
- Data - notes générales sur les données - ORM - DAL - Data mapper pattern
Data Mapper (SQLAlchemy) vs Active record
Voir aussi :
- pandasql
- querycsv
- csvkit
- Object-Document Mapper (ODM)
- mincePy
Générique
Voir module :
- SQLAlchemy Core
- easy_db
Voir : urllib.parse
TinyDB
Une base de donnée native Python avec enregistrement dans fichier JSON (Ou Yaml en custom-storage)
Voir : https://www.docstring.fr/blog/tinydb-une-base-de-donnees-adaptee-vos-projets/
ORM
- SQLAlchemy ORM
- SQLObject
- Pony
- Peewee
- mincePy (data mapper pattern designed specifically for computational and data science)
- MasoniteORM
Database Abstraction Layer (DAL)
pyDAL
- pyDAL (web2py & py4web)
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer
Notes Python DB - ORM - DAL - SqlAlchemy
Voir Notes Python DB - ORM - DAL
Core & ORM :
Voir ORM :
Lib :
RestApi pour DB SqlAlchemy :
Notes SQLAlchemy Core
#import urllib.parse import sqlalchemy from sqlalchemy import create_engine, text engine = create_engine('sqlite:////home/jean/tmp/test-sqlite.db') # Exemple de SQL sql = text('SELECT * FROM contacts;') with engine.connect() as con: result = con.execute(sql) print(result.all()) result.close() # Exemple de code SQL conn = engine.connect() result = conn.execute(text("SELECT * FROM contacts")) for row in result: print(row) # Exemple de Select from sqlalchemy import select stmt = select(User).where(User.name == "spongebob") # Introspection import Table metadata=MetaData() with engine.connect() as conn: table_contacts_reflected==Table("contacts", metadata, autoload_with=conn) print(table_contacts.c) print(table_contacts.primary_key) # Champs descriptions conn = engine.connect() result = conn.execute(text("SELECT * FROM contacts")) cursor=result.cursor print(';'.join([ x[0] for x in cursor.description]))
Autres
Dataset
Voir :
Dataset: databases for lazy people
import dataset db = dataset.connect('sqlite:///:memory:') table = db['sometable'] table.insert(dict(name='John Doe', age=37)) table.insert(dict(name='Jane Doe', age=34, gender='female')) john = table.find_one(name='John Doe')
Notes Python config
A new environment variable in Python to control parsing of email addresses
To mitigate CVE-2023-27043, a backward incompatible change to ensure stricter parsing of email addresses was introduced in Python 3.
This update introduces a new PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSING environment variable. When you set this variable to true, the previous, less strict parsing behavior is the default for the entire system:
export PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSING=true
However, individual calls to the affected functions can still enable stricter behavior.
You can achieve the same result by creating the /etc/python/email.cfg configuration file with the following content:
/etc/python/email.cfg
[email_addr_parsing] PYTHON_EMAIL_DISABLE_STRICT_ADDR_PARSING = true
For more information, see the Knowledgebase article Mitigation of CVE-2023-27043 introducing stricter parsing of email addresses in Python.
Notes Python - les objects - Class
Exemples
class Geeks: def __init__(self): self._age = 0 # using property decorator # a getter function @property def age(self): print("getter method called") return self._age # a setter function @age.setter def age(self, a): if(a < 18): raise ValueError("Sorry you age is below eligibility criteria") print("setter method called") self._age = a mark = Geeks() mark.age = 19 print(mark.age)
Source : https://www.geeksforgeeks.org/getter-and-setter-in-python/
Install de Zabbix sous RedHat
Voir repopackages.php
wget http://yum.postgresql.org/8.3/redhat/rhel-5-x86_64/pgdg-redhat93-9.3-1.noarch.rpm rpm -Uvh pgdg-redhat93-9.3-1.noarch.rpm yum install postgresql93-server postgresql93-contrib service postgresql-9.3 initdb service postgresql-9.3 start su - postgres
CREATE ROLE zabbix WITH login password 'zabbix'; CREATE DATABASE zabbix owner zabbix;
pg_hba.conf
host all all 127.0.0.1/32 ident host all all 127.0.0.1/32 md5
Pour se connecter à la base :
psql -U zabbix -h localhost -W
Voir red_hat_enterprise_linux_centos
wget http://repo.zabbix.com/zabbix/2.2/rhel/5/x86_64/zabbix-release-2.2-1.el5.noarch.rpm rpm -Uvh zabbix-release-2.2-1.el5.noarch.rpm yum install php53-common php53-bcmath php53 php53-gd php53-xml php53-mbstring zabbix-web yum install zabbix-server-pgsql zabbix-web-pgsql yum install zabbix-get yum install zabbix-agent ls -l /usr/share/doc/zabbix-server-pgsql-2.2.2/create/ psql -U zabbix -h localhost -W -1 -f /usr/share/doc/zabbix-server-pgsql-2.2.2/create/schema.sql psql -U zabbix -h localhost -W -1 -f /usr/share/doc/zabbix-server-pgsql-2.2.2/create/images.sql psql -U zabbix -h localhost -W -1 -f /usr/share/doc/zabbix-server-pgsql-2.2.2/create/data.sql
vi /etc/httpd/conf.d/zabbix.conf
/etc/init.d/httpd restart php_value date.timezone Europe/Paris
chkconfig --add zabbix-agent
service zabbix-agent start
http://localhost:8081/zabbix
http://localhost:8081/zabbix User : Admin Mdp : zabbix
/etc/zabbix/zabbix_agentd.conf
#Server=127.0.0.1 Server=10.252.64.210
Exemple d'utilisation zabbix_get (depuis un serveur autorisé) :
zabbix_get -s elp -k 'agent.version' yum install zabbix-java-gateway /etc/init.d/zabbix-java-gateway start chkconfig --add zabbix-java-gateway
