Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
"Python is a programming language that lets you work quickly and integrate systems more effectively."
Python is a C like scripting language with many additional modules to handle all sorts of tasks. As editor you can either use Eclipse with PyDev (in our examples it is used with the Eclipse CPP edition) or PyCharm from JetBrains. PyCharm offers full integration with python including management of modules and environments, support for GAE, Flask, ...
Python dependencies are managed through a local requirements.txt file listing all dependencies. Usually a
pip install -r requirements.txt
is run to install dependencies.
You can create a dependency file by
pip freeze > requirements1.txt
Common modules used in yafra:
- PyMySQL and/or official Mysql Connector Python (install via tar file if you run Python27 and Pyhton3 on the same machine)
- SQLAlchemy (and sqlacodegen to generate models out of legacy)
Eclipse CPP edition with PyDev is used as IDE. ActivePython (32bit as those enables free access to required modules) 2.7 is used.
The standard python unittest is used. The default structure is a directory "test" and put your test python scripts into this folder. With python 3 you can execute python3 -m unittest test/TestApp.py and with python 2 you can execute python -m unittest test.TestApp.
Direct MySQL script
Simple query of database with direct DB API (mysql-connector in this example). https://github.com/yafraorg/yafra-tdb-python/tree/master/utils/mysql-connector
Simple query with MySqlDB driver - working on Python 2.7 and Python 3 https://github.com/yafraorg/yafra-tdb-python/tree/master/utils/db-api
A python ORM which has a utility to reverse engineer existing databases and create python model files.
./sqlacodegen mysql+pymysql://yafraadmin:yafra@localhost/yafra > model.py
Afterwards SQL Alchemy can be used with this model. https://github.com/yafraorg/yafra-tdb-python/tree/master/utils/alchemy
A python example using Gtk/Glade as user interface framework and communicating with a daemon using a character based TCP socket communication. See the Python-GTK3 example and code: https://github.com/yafraorg/yafra-tdb-python/tree/master/admin-ui
Google App Engine
A web based example using GAE Big Table datastore.
- a full example of an app engine using python (based on webapp2/jinja2)
A web based example using Flask/Eve. Similar to GAE but independent of GAE environment. Can be used on OpenShift.
- Flask with SQL Alchemy
- using OpenShift or own environment