Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jnsougata/ssqlite3
A simple wrapper around Deta Base to use SQLite3 in Python
https://github.com/jnsougata/ssqlite3
deta-base deta-space nosql sqlite3
Last synced: about 16 hours ago
JSON representation
A simple wrapper around Deta Base to use SQLite3 in Python
- Host: GitHub
- URL: https://github.com/jnsougata/ssqlite3
- Owner: jnsougata
- License: mit
- Created: 2023-06-23T06:01:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-08T04:00:56.000Z (about 1 year ago)
- Last Synced: 2024-10-12T20:06:27.172Z (about 1 month ago)
- Topics: deta-base, deta-space, nosql, sqlite3
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ssqlite3
## Installation
```bash
pip install git+https://github.com/jnsougata/ssqlite3.git
```# Usage
```python
from ssqlite3 import SQLBase# Create a database
db = SQLBase(
db_name="sqldb",
project_key="collection_key"
)
db.connect()
```
```python
# Create a table and insert some data
db.conn.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)")
db.conn.execute("INSERT INTO users (id, name, age) VALUES (1, 'John', 25)")
db.conn.execute("INSERT INTO users (id, name, age) VALUES (2, 'Jane', 22)")
db.conn.execute("INSERT INTO users (id, name, age) VALUES (3, 'Bob', 30)")
db.conn.execute("INSERT INTO users (id, name, age) VALUES (4, 'Alice', 27)")
db.commit()
``````python
# Add new attr to the table
db.conn.execute("ALTER TABLE users ADD city TEXT")
db.commit()
``````python
# Update data
db.conn.execute("UPDATE users SET city='New York' WHERE id=1")
db.commit()
``````python
# print all the users with name starting with J
users = db.conn.execute("SELECT * FROM users WHERE name LIKE 'J%'").fetchall()
print(users)
```
- don't forget to commit the changes after doing a bunch of oprations.