connect table settings of a sqlite database with a ini file for better editing
Project description
SQIni
The purpose of this package is to have a simple method of revising tables in a SQLite database. It is also possible to convert current tables as ini files.
There is a protection that prevents you from deleting data by removing something from the ini
The following options can currently be used, the others are not functional
sqini.Database()
read()
syncToDatabase()
syncToIni()
.db
Install the pip
pip install sqini
How to use
Import SQIni in your script
import sqini
define SQIni
import sqini
database = sqini.Database() # enter the configurations here (iniSync, canDelete)
database.read('database path') #here you have to specify the database and the path
Setup the sync from a ini file with your sqlite database
A SQLite databse must endig with .db
.
The ini file must have the same name as the sqlite database, it is found automatically when reading, if none is available one is created. If no path to a database is given, a database is created once. However, it will not be read in automatically when the program is started again.
example script
import sqini
database = sqini.Database()
database.read('./mydata.db')
database.syncToDatabase()
There is a security that prevents files from being deleted should an entry be removed from the ini file. This can be switched off with canDelete = True
when initializing-
Important! If the file is in the same directory put a . /
In front, this is required, otherwise the path is missing. If another path is specified, it does not have to be specified
Sync your current database with a ini file
Safety first, for syncing a database with a ini you need allow it with iniSync=True
, it should protect against unintentional editing
if you do not allow it, a warning message will appear and it will not be carried out
import sqini
database = sqini.Database(iniSync=True)
database.read('./mydata.db')
database.syncToIni()
Use the normal database
it is also possible to control the database via sqlite3 without having to define it again
As example with execute. The db
variable is the normal sqlite3 connection.
import sqini
database = sqini.Database(iniSync=True)
database.read('./mydata.db')
database.db.execute() # as example
THE INI FILE
the ini file must have the same name as the database, only it must end with .ini
. You do not have to specify this when reading in because it derives it
An ini file is structured as follows so that it works
Always only ONE space as spacing, otherwise errors will occur. In the default_value
this does not matter if you use a string.
If you do something wrong, no data will be damaged, there will be an error beforehand.
[user]
id = INTEGER 0 0 0 0
name = TEXT 0 0 0 0 'unbekannt'
money = INTEGER 0 0 0 0 1000
inventory = TEXT 0 0 0 0 '{}'
description = TEXT 0 0 0 0
construction
[user]
- that's the table name - you can enter what you want hereid
,name
- that's the column name - you can enter what you want here- Types - SQLite databases are of different types, all of which can be used
- Numbers, Here are 4 numbers, these mean in sequence
not_null
,primary_key
,autoincerment
andunique
.0
is deactivated and1
is activated. - The last is the default value that the column should have.
If you don't want to specify anything, don't write anything. Otherwise, write your desired value as a string with
'your string'
and a number like598
or2985.123
.
SQLite Types
INTEGER
- to save numbersTEXT
- to save text/stringsBLOB
,REAL
,NUMERIC
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file SQIni-0.0.6.tar.gz
.
File metadata
- Download URL: SQIni-0.0.6.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 390f2673a0c5b21c7f4d5ab69511b178e33857ae8b8c1d8c3db88c28f7768087 |
|
MD5 | 4018a5b42302a5cd77a928cb1bc38e1e |
|
BLAKE2b-256 | a890c809fa8645074423de0bdfec11e30fdce0efdfdc8f4cc59d63ce76c0d821 |
File details
Details for the file SQIni-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: SQIni-0.0.6-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79997449039d068596e71f471292b508a347615692c5d1b64806a407f001134f |
|
MD5 | 377ed7a0279dbb7dcd4f6077581f700d |
|
BLAKE2b-256 | 6ccc85e8b0c4ae4e8de6387e56507798c453f8e05c19fe72b0c17a9982fa96db |