Skip to main content
pypi: https://pypi.python.org/pypi/campbel/0.0.7

便利モジュールです。
現段階ではRDS、S3への接続のモジュールになります。

セットアップ
pip install campbel

チュートリアル
dbに接続しよう

from campbel.AWS import Rds as rds
rds = rds.Rds(
db_host = 'DBホスト',
db_user = 'DBユーザー',
db_password = 'DBパスワード',
db_name = 'DB名',
charset = 'utf-8',
debug=False
)

これで接続完了!

sql文を実行してみよう
sql = ''
rds.sqlExecute(sql)
rds.dbClosed()
これで任意のsql文を実行できます!
以下を使うと高速にかつ正確にsql文が実行できます。(内部ではsqlExecute()が実行されています。)

インサートしよう
辞書形式を配列にしましょう。
data_list_array = [
{'name':'ryu', age:27, 'massage':'こんにちは'},
{'name':'koumei', age:26, 'massage':'game'},
{'name':'hyuga', age:21, 'massage':'meshi'},
{'name':'kenjo', age:20, 'massage':'study'},
]
r = rds.insertListExecute('user', data_list_array)
これは
INSERT INTO user (name,age,message) VALUES ("ryu",27,"こんにちは")
INSERT INTO user (name,age,message) VALUES ("koumei",26,"game")
INSERT INTO user (name,age,message) VALUES ("hyuga",21,"meshi")
INSERT INTO user (name,age,message) VALUES ("kenjo",20,"study")
と等価です。

取得してみよう
r = rds.insertListExecute('user', 'name', where='')
data = r.fetchall()
これは
SELECT name FROM user
と等価です。

アップデートしてみよう
r = rds.updateListExecute('user', {'age':8, 'where':'name="ryu"'}, where='where')
これは
UPDATE user SET age=8 WHERE name="ryu"
と等価です。


なお、
r._executedで実行した一番最後のsqlが確認できます。(複数まとめて実行した場合は一番最後のsqlの表示になります。)
もしその都度確認したければ、インスタンスを作る段階でdebug=Trueとしてください。



次はs3に接続してみよう!

from campbel.AWS import S3 as s3

s3 = spython setup.py register3.S3(
access_key = 'アクセスキー',
secret_access_key = 'シークレットアクセスキー',
bucket_name = 'バケット名',
)

これで接続完了です。

S3の/test/とディレクトリを作ろう。
s3.createDir('test/')

ローカルのa.txtをデータを入れよう!
s3.uploadFileToS3(a.txt, 'test/a.txt')



















<!-- -->


Metadata

Release files for campbel 0.0.42

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for campbel 0.0.42
File Size Uploaded Provenance Actions
campbel-0.0.42.tar.gz 6.0 kB Without provenance Details for campbel-0.0.42.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for campbel 0.0.42
File Interpreter ABI Platform Actions
campbel-0.0.42-py2-none-any.whl Python 2 none any Details for campbel-0.0.42-py2-none-any.whl

Total release size: 15.6 kB

Release files / campbel-0.0.42.tar.gz

Download URL campbel-0.0.42.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8c8b752c513b3ce86158185fda6911acd7e8d7fc64b4541bede40b736aae7d63
BLAKE2b-256 checksum
How to use checksums
1cca7cf0d97c441918fd9e3994bc7df2bd312ba0d825cb37704b71be6b8101f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / campbel-0.0.42-py2-none-any.whl

Download URL campbel-0.0.42-py2-none-any.whl
Size 9.6 kB
Tags Python 2
SHA-256 checksum
How to use checksums
664e5dfde19944a9ea3ab8f8e4c4f58bbf2293ba499bb765fac0b657c1ff6a6c
BLAKE2b-256 checksum
How to use checksums
ba22f54faf284e47ccc0b77c7de1d6a6f4fd1b8f4f6f77e84623a64b8dc1a0d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for campbel 0.0.42

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.42 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page