Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/muntashirakon/python-sqlite
SQLite module for Python with PHP MySQLi like syntax
https://github.com/muntashirakon/python-sqlite
Last synced: 30 days ago
JSON representation
SQLite module for Python with PHP MySQLi like syntax
- Host: GitHub
- URL: https://github.com/muntashirakon/python-sqlite
- Owner: MuntashirAkon
- License: mit
- Created: 2015-10-20T07:21:11.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-02T14:20:47.000Z (almost 9 years ago)
- Last Synced: 2024-04-14T02:59:37.678Z (9 months ago)
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python SQLite
SQLite Database handler in Python with PHP-MySQLi like syntax## Builds
master: [![Build Status](https://travis-ci.org/MuntashirAkon/Python-SQLite.svg?branch=master)](https://travis-ci.org/MuntashirAkon/Python-SQLite)
v0.1.0: [![Build Status](https://travis-ci.org/MuntashirAkon/Python-SQLite.svg?branch=v0.1.0)](https://travis-ci.org/MuntashirAkon/Python-SQLite)## Documentation
Full documentation is covered in the [wiki page](https://github.com/MuntashirAkon/Python-SQLite/wiki).Here's an quick example:
``` python
from sqlite import SQLite
# notice: you don't need to import sqlite3 modulesqlite = SQLite(":memory:")
# creates table
stmt = sqlite.prepare("""CREATE TABLE sample (
ID integer PRIMARY KEY AUTOINCREMENT NOT NULL,
Name text
)""")
stmt.execute()
stmt.close()# insert a value
name = "Muntashir"
stmt = sqlite.prepare("INSERT INTO sample (Name) VALUES (?)")
stmt.bind_param('s', name)
stmt.execute()
if stmt.affected_rows > 0:
print(stmt.affected_rows, "rows added.")
print("inserted id:", stmt.insert_id)
stmt.close()# select from table
stmt = sqlite.prepare("SELECT * FROM sample")
stmt.execute()
stmt.store_result()
if stmt.num_rows > 0:
name = []
id = []
print("ID\tName")
for i in range(0, stmt.num_rows):
stmt.bind_result(id, name)
stmt.fetch()
print("{}\t{}".format(id[0], name[0]))
stmt.close()
sqlite.close()
```## Contribute
Contribution is always welcome. If you have better ideas or coding, you can always create a pull request or new issue.## License
This project is licensed under [MIT License](https://github.com/MuntashirAkon/Python-SQLite/blob/master/LICENSE)