kieran-lock / sqliteframe Goto Github PK
View Code? Open in Web Editor NEWA lightweight, zero-dependency ORM for SQLite in Python
Home Page: https://pypi.org/project/SQLiteFrame/
License: MIT License
A lightweight, zero-dependency ORM for SQLite in Python
Home Page: https://pypi.org/project/SQLiteFrame/
License: MIT License
When writing data to string field, the string in the SQLite DB contains not only the string value, but also a pair of double quotes.
It looks like the SQL INSERT or UPDATE statement contains '"MyString"'
instead of 'MyString'
for the values.
When creating a table, the fields are generated in alphabetical order. The order from the class in the python code is not preserved.
This class from the project example
@table(database)
class TableName:
primary_key_field = String(primary_key=True) # The primary key parameter is False by default
second_column = Integer # If only the default options are required, no brackets are necessary either
third_column = Boolean(nullable=True) # The nullable parameter is False by default
fourth_column = String(default="This is a default value.") # You can also opt-in to giving columns default values like this
leads to this debug output:
CREATE TABLE IF NOT EXISTS TableName (
fourth_column TEXT NOT NULL DEFAULT "This is a default value.",
primary_key_field TEXT PRIMARY KEY NOT NULL,
second_column INTEGER NOT NULL,
third_column BOOLEAN
);
fourth_column
should be the last item in the CREATE TABLE
statement, but it's the first, because the fields have been sorted alphabetically.
Hi
I'm trying to use your library, but on the first with the following code:
from sqliteframe import table, Integer, String, ForeignKey,Database
database = Database('bep.sqlite',output=True,foreign_keys=True)
@table(db)
class Alert:
id = Integer(primary_key=True)
creation_date = String(nullable=False)
last_update = String(nullable=False)
search_term = String(nullable=False)
def main():
insert_stmt = Offer.insert_into({
'ref':'124',
'tipo':'tipo'
})
insert_stmt.execute()
if __name__ == '__main__':
main()
if fails on Windows in Python 3.10.4 (Anaconda) with the error:
Traceback (most recent call last):
File "s:\bep_alerter\models.py", line 6, in <module>
@table(database)
TypeError: 'module' object is not callable
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.