Table des matières
- 2026:
- 2025:
13 billet(s) pour novembre 2026
| Réseaux - protocole QUIC mieux que TCP | 2026/11/17 21:26 | Jean-Baptiste |
| Notes conversion JSON YAML | 2026/11/13 11:16 | Jean-Baptiste |
| Git commit perdu | 2026/11/12 18:16 | Jean-Baptiste |
| Notes mojo lang | 2026/11/11 20:34 | Jean-Baptiste |
| Notes rust lang compilation | 2026/11/11 18:35 | Jean-Baptiste |
| Mémoire VSIZE VMSIZE SEGV lang C | 2026/11/11 15:59 | Jean-Baptiste |
| Ansible-navigator utilisation de ansible-vault | 2026/11/06 11:33 | Jean-Baptiste |
| Err Ansible - Module result deserialization failed No start of json char found | 2026/11/06 09:09 | Jean-Baptiste |
| Script Python conversion JSON vers CSV | 2026/11/06 08:14 | Jean-Baptiste |
| Filter Incoming IPv4 Packets Containing IP Options - cve-2026-98432 mitigation - Kernel TCP Use-After-Free | 2026/11/04 21:04 | Jean-Baptiste |
| Notes ZFS | 2026/11/03 18:04 | Jean-Baptiste |
| Diff image container | 2026/11/03 16:30 | Jean-Baptiste |
| Notes processus multi-thread | 2026/11/03 10:59 | 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
