直接在python数据上播放sql
baresql的Python项目详细描述
baresql:直接在python数据上播放sql
- baresql提高了python数据科学初学者的sql敏捷性:
- 允许sql覆盖python对象(列表、范围,…)和sql表,
- 不需要特殊模块,除了:熊猫。
灵感:
- pypi.python.org/pypi/pandasql:sqldf用于熊猫
- pypi.python.org/pypi/ipython-sql:ipython中的sql魔术
功能
- 查询列表、元组、字典、数据帧
- 结果为数据帧、记录列表或列表
- 旧python3.3版本上的基本公共表表达式支持
安装
您可以使用以下命令安装、升级和卸载sqlite_bro.py:
$ pip install baresql $ pip install --upgrade baresql $ pip uninstall baresql
或者用%loadhttps://raw.githubusercontent.com/stonebig/baresql/master/baresql/baresql.py从ipython启动它
基本示例
from __future__ import print_function, unicode_literals, division # if Python2.7 from baresql import baresql bsql = baresql.baresql(keep_log = True ) bsqldf = lambda q: bsql.df(q, dict(globals(),**locals())) users = ['Alexander', 'Bernard', 'Charly', 'Danielle', 'Esmeralda', 'Franz'] # We use the python 'users' list like a SQL table sql = "select 'Welcome ! ' , c0 from users$$" bsqldf(sql)
变更日志
2016-09-18a:v0.7.4“熊猫漫步”
- 错误修复:pandas 0.19兼容性修复
旧版本:
- 0.7.3 : Python keyword is ‘pass’, not ‘Pass’
- 0.7.2 : support space in dataframe column title
- 0.7.1 : cleanups
- 0.7.0 : support of pandas 0.14 sqlalchemy
- 0.6.6 : sqlite_py_manager.py browser added functions and fix, fix tokenizer error in baresql
- 0.6.4 : minimal compatibility of sqlite_py_manager.py with old versions : python 2.7 and sqlite 3.6.21
- 0.6.1 : a pure standard-installation Python SQLite browser in examplessqlite_py_manager.py
- 0.6 : first version with correct mysql support
- 0.5.1 : bug correction + SQLite3.8.3 beta from 2013-01-22
- 0.5 : use SQLite true CTE if SQLite >= 3.8.3
- 0.4.1 : inline CTE when syntax is “with x as (y)”
- 0.4 : rewrite with token
- 0.3.2 : support comments in the SQL
- 0.3 : includes a basic CTE
- 0.2 : add “range(10)” iterable object support
- 0.1 : initial version