Make it easier to build database/table/seeders for DBMS or framework like laravel
Project description
CSV to DB
With this package you will be able to get info from a csv file like the column name, or specific row, and update your file with the possibility to add row or column.
The most important with this tool is you can easily transform your csv to, SQL scripts to build table or create seeder for your database (you can build them both in the same file).
Supported
DBMS
DBMS | Engine | >= Ver. |
---|---|---|
Mysql |
|
8.0 |
Framework
Framework | >= Ver. |
---|---|
Laravel | 8.x |
CSV
Features
- Get total columns in the file
- Get list of rows
- Get column content
- Get column name
- Get total rows in the file
- Update column name
- Set new row
- Update row
- Build json file
- Format column name to get right syntax (remove whitespace)
- Getter and setter for:
- filename
- filepath
- delimiter
- quotechar
How to build your csv
Your csv must respect some rules to be understandable correctly and for everything to works well
Column name
Column name whitespace needs to be replaced by underscore like => column_name method in this package can format them too
Date type
The syntax for the date must be one of those to be detected like date:
- dd/mm/yyyy 00:00:00
- dd/mm/yyyy
- yyyy
- 00:00:00
Number which have to be string
Example for a product reference if you want it to be string value you have to add non-numeric value like => '456789132'
Primary key
generate automatically don't worry
Foreign key
For the foreign key column name must be => tableReference_id
Usage
DBMS
Example with mysql:
Build new db
from csvtodb.Csv import Csv
from csvtodb.Mysql import Mysql
csv = Csv(filename='filename', filepath='filepath')
Mysql.new_db(save_in='filepath', name='db_name') # name is the db and filename
Build new table
from csvtodb.Csv import Csv
from csvtodb.Mysql import Mysql
csv = Csv(filename='filename', filepath='filepath')
# engine is optional the default value is InnoDB
# You can add temporary too which is optional default value is False
Mysql.new_table(csv=csv, filename='filename', filepath='filepath', engine='InnoDB')
Build multiple table
from csvtodb.Csv import Csv
from csvtodb.Mysql import Mysql
csv = Csv(filename='filename', filepath='filepath')
Mysql.new_tables(filepath='save_in', filename='sql_filename', files={
'csv_files_path_1': ('filename1', 'filename2'),
'csv_files_path_2': ('filename1', 'filename2')
})
Build new seeder
from csvtodb.Csv import Csv
from csvtodb.Mysql import Mysql
csv = Csv(filename='filename', filepath='filepath')
Mysql.new_seeder(csv=csv, filename='filename', filepath='filepath')
Framework
example with Laravel:
Build new migration file
from csvtodb.Csv import Csv
from csvtodb.Laravel import Laravel
csv = Csv(filename='data_test', filepath='csv_file')
Laravel.new_migration(csv=csv,
filepath='laravel_migration_folder',
filename='laravel_migration_filename')
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 csvtodb-0.0.1.tar.gz
.
File metadata
- Download URL: csvtodb-0.0.1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b6cd47ed5c2103d96b9c46cf6ff14b47042965606824d6d12f7c5aa0046f1c2 |
|
MD5 | 0faf6425b4176cb9e8e349b155437f7c |
|
BLAKE2b-256 | ce5f838f559395c346d902ecf2dd6de5fe162e90811acb4c48e45d2f9f172263 |
File details
Details for the file csvtodb-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: csvtodb-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40a58c402998ecb762169096739caef36f4e344a7837db71148563442ef50c14 |
|
MD5 | 2df706ee5d4234c992e5e78715a7a0be |
|
BLAKE2b-256 | dbd884000718f4039a97f7af34f2e8da4cfcc29a7871bc661b690c5c038ecdfe |