MPTT tree_id

MPTT Tree ID Django + mysql: transaction.atomic() で select_for_update() を使ってレコードをロックしたときのメモ MySQL で採番機能(シーケンス)を実装する方法を整理する MySQL のロックについて公式ドキュメントを読みながら動作検証してみた〜テーブルレベルロック〜 分散ロック Distributed Locking in Django 1 2 3 4 from django.core.cache import cache with cache.lock("somekey"): do_some_thing() redis-py: https://github.com/redis/redis-py/blob/d3a3ada03e080f39144807c9fbe44876c40e0548/redis/client.py#L394 デッドロック Hook available for automatic retry after deadlock in django and mysql setup 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import django.db.backends.utils from django.db import OperationalError import time original = django.db.backends.utils.CursorWrapper.execute def execute_wrapper(*args, **kwargs): attempts = 0 while attempts < 3: try: return original(*args, **kwargs) except OperationalError as e: code = e.args[0] if attempts == 2 or code != 1213: raise e attempts += 1 time.sleep(0.2) django.db.backends.utils.CursorWrapper.execute = execute_wrapper

2023年11月6日 · 1 分

redis

Elasic Cache for Redis バージョン 1 2 3 4 5 $ redis-cli --version redis-cli 5.0.7 $ redis-server -v Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=66bd629f924ac924 接続: 1 REDIS_URL=redis://mycloud-stage-redis-nc.sigrvp.ng.0001.apne1.cache.amazonaws.com:6379/0 1 2 3 $ export $(cat .env|xargs) $ redis-cli -u $REDIS_URL PING PONG Python redis-py: https://github.com/redis/redis-py django-redis: https://github.com/jazzband/django-redis channels_redis: https://github.com/django/channels_redis クラスターモードへの接続 Cluster Client 1 2 3 4 5 6 7 8 9 import logging from redis.cluster import RedisCluster ENDPOINT = "mycloud-stage-redis-test.sigrvp.clustercfg.apne1.cache.amazonaws.com" logging.basicConfig(level=logging.INFO) redis = RedisCluster(host=ENDPOINT, port="6379") if redis.ping(): logging.info("Connected to Redis") django-redis: ...

2023年7月14日 · 1 分

Celery AWS ECS

Celery on ECS 【Python Celery】本番運用時に知っておくべき 10 のこと https://github.com/Alexmhack/Django-Celery-Redis-AWSEB Redis Celery + AWS Redis で使ってみる クラスターモード Redis >= 3.2 ElastiCache for Redis のクラスターモードについて調べてみる SQS broker としてつかえるが、 backend としては使えない(SQS + RabbitMQ/Redis/SQLAlchemy を考える) Celery + SQS on Django on Elastic Beanstalk Deploying Django on AWS: Setting up Celery and SQS Deploying Django Application on AWS with Terraform. Setting up Celery and SQS ECS running celery tasks and celery beat in ECS with Django docker compose ecs deploy aws tutorial: celery incompatible attribute #8040 AWS Batch を検討したけど AWS Fargate を採用した話 Celery Logging celery.app.log Three Ideas to Customise Celery logging handlers 標準出力: ...

2023年7月13日 · 1 分

EC2 mount EFS

AWS EC2 moutn EFS E2 からマウント 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #!/bin/bash EFS_ID="fs-0f90bd97a364a6e94" # PKG=amazon-efs-utils RES=$(dpkg --get-selections | grep $PKG) MOUNT_PATH="/efs" if [ -z "${RES}" ]; then apt update && apt upgrade -y && apt autoremove -y apt-get -y install binutils git clone https://github.com/aws/efs-utils cd efs-utils ./build-deb.sh apt-get install -y ./build/amazon-efs-utils*deb fi # if [ ! -d $MOUNT_PATH ]; then mkdir $MOUNT_PATH fi # mount -t efs $EFS_ID:/ $MOUNT_PATH

2023年7月12日 · 1 分

ltsv

ltsv 形式 http://ltsv.org/ https://github.com/hekyou/python-ltsv pip install ltsv To process LTSV files in Python, you can use the ltsv package available on PyPI ². Here is an example of how to use it: 1 2 3 4 5 import ltsv with open('file.ltsv') as f: for record in ltsv.reader(f): print(record) This code will read the LTSV file line by line and print each record as a dictionary ¹. ...

2023年6月16日 · 1 分

ndjson

ndjson https://github.com/rhgrant10/ndjson Snowflake: CREATE FILE FORMAT 【Python】Python ~ ndjson を扱う ~ tablib は ndjson をサポートしていない pandas は ndjson を読み込める

2023年6月14日 · 1 分

ijavascript

ijavascript https://n-riesco.github.io/ijavascript/index.html

2023年6月7日 · 1 分

Django: SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async

Jupyter: Django: SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async このエラーは、asyncコンテキストから同期的なコードを呼び出そうとした場合に発生するエラーです。 async-unsafeなコードを呼び出す場合は、asyncコンテキストからではなく、自分自身の同期関数で書き、それをasgiref.sync.syncを使用して呼び出すように修正する必要があります¹。 ¹: Django: SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async. - Stack Overflow ソース: Bing との会話 2023/5/4 (1) Django: SynchronousOnlyOperation: You cannot call this …. https://stackoverflow.com/questions/61926359/django-synchronousonlyoperation-you-cannot-call-this-from-an-async-context-u. (2) django.core.exceptions.SynchronousOnlyOperation after …. https://github.com/django/channels/issues/1464. (3) python - Django channels Async Websocket throwing Error …. https://stackoverflow.com/questions/63892884/django-channels-async-websocket-throwing-error-while-trying-to-use-database-quer. (4) Django channel occasionally gets error “cannot call this from …. https://stackoverflow.com/questions/69239657/django-channel-occasionally-gets-error-cannot-call-this-from-an-async-context. (5) python - Getting SynchronousOnlyOperation error Even after …. https://stackoverflow.com/questions/63149616/getting-synchronousonlyoperation-error-even-after-using-sync-to-async-in-django. DJANGO_ALLOW_ASYNC_UNSAFE 環境変数を使用することで、非同期コンテキストで SynchronousOnlyOperation エラーが発生した場合に警告を無効にすることができます¹。 ...

2023年5月4日 · 1 分

Django MPTT: values で tree_id が SELECT されてしまう

Django MPTT: values で tree_id が SELECT されてしまう 仕様である django-mptt の TreeQuerySet で values コールすると SQL に tree_id が追加されているのは、django-mptt がツリー構造を管理するために必要なカラムだからです²。tree_id は、同じツリーに属するノードに同じ値を持ちます²。例えば、以下のようなモデルがあるとします。 1 2 3 4 5 6 7 8 9 from django.db import models from mptt.models import MPTTModel, TreeForeignKey class Category(MPTTModel): name = models.CharField(max_length=50, unique=True) parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') class MPTTMeta: order_insertion_by = ['name'] このとき、以下のように values をコールすると、SQL に tree_id が追加されます²。 ...

2023年4月28日 · 1 分

ゼロパーティデータ

ゼロパーティデータ 行動データにおいて、顧客が意図的・積極的に企業と共有するデータ ファーストパーティデータ(企業が収集する行動データ) 行動データには、個人がサイトやアプリ全体、またはページ上で行う操作すべてが含まれます。 クリック操作や詳細な行動(マウスオーバー、スクロール、操作時間など)、セッション数、ユーザーのパーソナライズされた体験への関わり方なども含まれます。 ファーストパーティデータがあれば、ユーザーの関心や意図を示す貴重な指標を収集できます。 購入やダウンロードなどの取引データも、ファーストパーティデータに分類されます。 サードパーティデータ(企業が他団体から取得する行動データ) 自社保有していないサイトや情報源から取得、または購入したデータを指します。 パーソナライズで通常使用されるサードパーティデータには、人口統計情報、企業データ、購入意思(新築住宅市場やソフトウェアの市場などの場合)と、CRM、POS、コールセンターなどから得た付加情報があります。 ゼロパーティデータ(顧客が意図的に企業に預けるデータ) Forrester Research社(英語)によって提唱された造語で、明示的なデータとも呼ばれます。 顧客が意図的・積極的に企業と共有するデータです。 ゼロパーティデータには、メールプリファレンスのデータ、購入意思、個人的背景、ユーザーが企業に『自分』をどのように認識してほしいかなどが含まれます アンケート、聞き取りなど チャットコマース 参照 GDPR:(General Data Protection Regulation:一般データ保護規則)(EU加盟国に同一に直接効力を持つ) CCPA:(カリフォルニア州消費者プライバシー法: California Consumer Privacy Act) Bing ゼロパーティデータとは、顧客が意図的・積極的に企業と共有するデータのことです¹。顧客の趣味嗜好や興味関心の情報が含まれ、パーソナライズやキャンペーンを推進するのに役立ちます²³⁴。 ソース: Bing との会話 2023/4/15 (1) ゼロパーティデータとは? | セールスフォース・ドットコム. https://bing.com/search?q=%e3%82%bc%e3%83%ad%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%83%87%e3%83%bc%e3%82%bf アクセス日時 2023/4/15. (2) ゼロパーティデータとは? | セールスフォース・ジャパン. https://www.salesforce.com/jp/resources/articles/what-is-zero-party-data/ アクセス日時 2023/4/15. (3) 今さら聞けない話題の「ゼロパーティ・データ」とは? | JP …. https://www.criteo.com/jp/blog/what-is-zero-party-data/ アクセス日時 2023/4/15. (4) DX時代のカギを握る「ゼロパーティデータ」とは?いま重要視さ …. https://www.powerweb.co.jp/blog/entry/2022/03/15/100000 アクセス日時 2023/4/15. ゼロパーティデータは、様々な方法で活用できます。例えば、¹⁴⁵ 商品やサービスの改善に生かす 業務改善に生かす 新商品の開発に生かす パーソナライズやキャンペーンの強化に生かす ゼロパーティデータを活用するには、顧客IDや個人情報と紐づけて蓄積し、セグメントとして切ることが必要です²。 ソース: Bing との会話 2023/4/15 (1) ゼロパーティデータとは?ゼロパーティデータが重視される …. https://bing.com/search?q=%e3%82%bc%e3%83%ad%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%83%87%e3%83%bc%e3%82%bf%e3%81%ae%e6%b4%bb%e7%94%a8%e6%96%b9%e6%b3%95 アクセス日時 2023/4/15. (2) ゼロパーティデータの概要からおすすめの活用法まで. https://data.wingarc.com/allabout_zero-party-data-39612 アクセス日時 2023/4/15. (3) ゼロパーティデータとは?重要視すべき3つの理由と収集方法を …. https://www.transcosmos-cotra.jp/zero-party-data アクセス日時 2023/4/15. (4) Cookieレス時代に「ゼロパーティデータ」が生み出す真の顧客 …. https://www.ever-rise.co.jp/dx-blog/zero-party-data/ アクセス日時 2023/4/15. (5) ゼロパーティデータとは? | セールスフォース・ジャパン. https://www.salesforce.com/jp/resources/articles/what-is-zero-party-data/ アクセス日時 2023/4/15. ゼロパーティデータを収集するには、顧客に対価を提供して、自発的に情報を提供してもらうことが必要です¹²。対価としては、割引やクーポン、プレゼントなどがあります。また、設問内容や回答方法を吟味して、顧客の興味やニーズに合わせた内容にすることも大切です¹。 ...

2023年4月15日 · 1 分