Skip to main content

Micro ORM SQLite3

Project description

FastSQLite Documentation

Example

from fastsqlite import FastSQLite

db = FastSQLite()
db.connect('file.db')
db.create_table('gato', 'id int, rum varchar(300)')

Using FastSQLite

db = FastSQLite()

db.connect( file):

db.connect('database.db')

Important:

ALTERtable [table] RENAME TO [rename];
[variable] = variable: str

db.rename_table(str, str)

example:
	db.rename_table('old_name', 'new_name')

Table Actions

db.create_table(table, columns):

CREATEtable [table]([columns]);

db.rename_table(table, rename):

ALTERtable [table] RENAME TO [rename];

db.drop_table(table):

DROPtable [table];

Column Actions

db.insert(table, column, params):

INSERT INTO [table]([column]) VALUES([params]);

db.update(table, params, where, condition):

UPDATE [table] SET [params] WHERE [where] = [condition];

db.delete(table, where, condition):

DELETE FROM [table] WHERE WHERE [where] = [condition];

db.add_column(table, new_column):

ALTERtable [table] ADD COLUMN [new_column];

db.add_fk_reference(table, fk_column, column_id):

FOREIGN KEY([fk_column]) REFERENCES [table]([column_id]);

Queries Section

db.custom_fetch( query):

query = 'SELECT nombre as n, precio as p FROM productos WHERE precio < 5.60;'
db.custom_fetch(query):

db.fetch_all(table):

SELECT * FROM [table];

db.fetch_one(table, column):

SELECT [column] FROM [table];

db.fetch_many(table, columns):

SELECT [columns] FROM [table];

db.distinct(table, columns):

SELECT DISTINCT [columns] FROM [table];

db.where(table, columns, where, param):

SELECT [columns] FROM [table] WHERE [where] = [param];

db.like(table, columns, param):

SELECT [columns] FROM [table] LIKE [param];

db.between(table, columns, where, param1, param2):

SELECT [columns] FROM [table] WHERE [where] BETWEEN [param1] AND [param2];

db.left_join(table1, table2, columns, column1, column2):

SELECT [columns] FROM [table1] LEFT JOIN [table2] ON [table1].[column1]=[table2].[column2];

db.right_join(table1, table2, columns, column1, column2):

SELECT [columns] FROM [table1] RIGHT JOIN [table2] ON [table1].[column1]=[table2].[column2];

db.inner_join(table1, table2, columns, column1, column2):

SELECT [columns] FROM [table1] INNER JOIN [table2] ON [table1].[column1]=[table2].[column2];

db.union_all(table1, table2, columns_table1, columns_table2):

SELECT [columns_table1] FROM [table1] UNION ALL SELECT [columns_table2] FROM [table2];

db.union(table1, table2, columns_table1, columns_table2):

SELECT [columns_table1] FROM [table1] UNION SELECT [columns_table2] FROM [table2];

db.avg(table, column, name, where, param):

SELECT AVG([column]) AS [name] FROM [table] WHERE [where] = [param];

db.count(table, column, name, where, param):

SELECT COUNT([column]) AS [name] FROM [table] WHERE [where] = [param];

db.sum(table, column, name, where, param):

SELECT SUM([column]) AS [name] FROM [table] WHERE [where] = [param];

db.max(table, column, name, where, param):

SELECT MAX([column]) AS [name] FROM [table] WHERE [where] = [param];

db.min(table, column, name, where, param):

SELECT MIN([column]) AS [name] FROM [table] WHERE [where] = [param];

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastsqlite-1.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page