Access Point Module to CSSAW Database
Project description
CSSAW_Central
Installation
pip install cssaw-central
Usage
csvsql script
The package comes with a script to automatically upload a csv file to the given table in a sql database. It takes user, pass, host IP, database, table, and cSV file path as arguments
csvsql -h
usage: csvsql [-h] user password host database table filename
positional arguments:
user user for database login
password password for login if necessary
host host IP for database
database database to run queries on
table table to insert into (will create new if doesn't exist)
filename filepath of CSV file to insert
optional arguments:
-h, --help show this help message and exit
--overwrite Overwrite already-present table in database
example
csvsql test test HOST Test test_table ./TestDocs/test.csv
The above example connects to the Test database using the test user and inserts the test.csv file into test_table.
Session module
Session object acts as a wrapper for sqlalchemy connection. The connection is created and stored in the Session object at initialization, and any results can be taken from the self.conn object or, if using execute_sql(), can be taken from the returned results python list.
Example:
from cssaw_central.Session import Session
sess = Session('username','password', 'localhost', db='Test')
sess.create_table('test_table', ['column1', 'column2', 'column3'], \
[int, int, int])
sess.insert('test_table', ['column1', 'column2', 'column3'], [0, 1, 2])
print(sess.execute_SQL('./queries/test.sql'))
The above script will create a connection to the Test database at localhost:3306 (assuming that it exists), insert the given values into their appropriate columns in test_table, and then execute test.sql from the queries file.
License
Project details
Release history Release notifications | RSS feed
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 cssaw_central-1.3.0.tar.gz
.
File metadata
- Download URL: cssaw_central-1.3.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47cffd00029dd67713d4982a3dbf00fdbd46c837bda260022a137fa35435068a |
|
MD5 | d95e3e2bf81b36dbccb3bcc4eecbf0b5 |
|
BLAKE2b-256 | c50f7c781fa76abf14698d580616cf6bc1aa75d54438271e66abe39f19902138 |
File details
Details for the file cssaw_central-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: cssaw_central-1.3.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b9ae7d9f9c4127a3175cc6745a599faceef9b6034546be9bcae0d8558f98820 |
|
MD5 | d53793b013cf8a51d1fdd42bef884835 |
|
BLAKE2b-256 | fec8d39d75260e53a0c8e88430b46bdf1708683723f6fd546473e61525ea8563 |