Path base SQL Query
Project description
SQLRaw
SQLRaw is a library that makes it easy to run .sql files that work with a SQLAlchemy.
First of all, SQLAlchemy connection definition are made
connstr = "postgresql://user:psw@host/database"
engine = create_engine(connstr, echo=False)
conn = engine.connect()
Read & Execute Current Sub Folders SQL File
sql = SqlRaw.current()
sql.load("person").connect(conn)
list = sql.fetchone({"id": 1})
In this example, the file "person.sql" is searched and executed in the current folder or subfolders. If there is a parameter definition such as ":id" in SQL, a value can be assigned to the "fetchone" method as a parameter.
Also Note that "fetchone" can be used instead of "fetchall"
Reading a file in a specific folder
sql = SqlRaw.paths(["/model"])
Use Cache
sql.cache_prefix = "app-name-prefix"
sql.cache(host='', port=6379, password='')
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
sqlraw-0.1.4.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file sqlraw-0.1.4.tar.gz
.
File metadata
- Download URL: sqlraw-0.1.4.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.10 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2c2c6f1e0b97b5b788449721552475970622c9e092425d5d03866980cf926d5 |
|
MD5 | bfa75faf9ef628aa2661b80245750eb7 |
|
BLAKE2b-256 | 07cd1d20a0417a7358dd87c0371fb603e8869610d879402bda90cda85182aa22 |
File details
Details for the file sqlraw-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: sqlraw-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.10 Darwin/22.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5b4f9ce16e0027badb6bc5c350a1cb644cf0dd4bb83f92e58a7340fd61095d5 |
|
MD5 | b77f67ca3491bc0ec24efacd3c00f390 |
|
BLAKE2b-256 | 8561b46f08b1922c042b087d69f07f7095fa3ec2245ceec411e82b33ecf80185 |