简单修改pugsql 使其支持直接执行sql。
使用
from hisql import *
from datetime import datetime
q = hisql()
q.connect('mysql+pymysql://bbq:bbq@localhost/bbq')
# 选择9.1号前10个接近10块股票
res = q.execute('select a.code as code, b.name as name, a.close as close '
'from stock_daily a left join stock_info b on a.code=b.code '
'where a.trade_date=:trade_date and a.close < 10 order by close desc limit 10',
Many(), trade_date=datetime(year=2021, month=9, day=1))
data = [d for d in res]
data
结果
[{'code': 'sz002820', 'name': '桂发祥', 'close': Decimal('9.9900')},
{'code': 'sz002556', 'name': '辉隆股份', 'close': Decimal('9.9700')},
{'code': 'sz002322', 'name': '理工环科', 'close': Decimal('9.9700')},
{'code': 'sz000920', 'name': '南方汇通', 'close': Decimal('9.9600')},
{'code': 'sz002545', 'name': '东方铁塔', 'close': Decimal('9.9600')},
{'code': 'sz002926', 'name': '华西证券', 'close': Decimal('9.9600')},
{'code': 'sh603056', 'name': '德邦股份', 'close': Decimal('9.9600')},
{'code': 'sz300434', 'name': '金石亚药', 'close': Decimal('9.9500')},
{'code': 'sz300437', 'name': '清水源', 'close': Decimal('9.9400')},
{'code': 'sz300030', 'name': '阳普医疗', 'close': Decimal('9.9300')}]
Metadata
Release files for hisql 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hisql-0.0.2.tar.gz | 3.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hisql-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 kB
Release files / hisql-0.0.2.tar.gz
| Download URL | hisql-0.0.2.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f55a3ff25f03706d6c8046801d6272f8b735ec7eed31af1604a24bb854b7d4d1
|
|
BLAKE2b-256 checksum How to use checksums |
4409131dd6f8417299715366987021c5bb44a038cfe219ffb65af3440e5eb3b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.0
|
Release files / hisql-0.0.2-py3-none-any.whl
| Download URL | hisql-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee4c9fac6a978df463ac232884aadeafea46f9bf814d9e8447862704083704cd
|
|
BLAKE2b-256 checksum How to use checksums |
af9cc5651ace26036f56641d06361ba41bc434c588dc90a70de6f125a9e0fec6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.0
|