![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Flexible SQL query builder written in Python! This library allows you to build and execute SQL queries with ease, while supporting dynamic parameters and JSON encoding for database compatibility.
natural_query_lib is a lightweight Python library designed to simplify SQL query building and execution. It combines a fluent API with dynamic parameter binding and JSON support, making it easier for developers to work with SQL databases in an efficient and Pythonic way.
SELECT
, INSERT
, UPDATE
, and DELETE
queries with a clean, fluent interface.asyncpg
.Install the library directly from PyPI:
pip install natural_query_lib
from natural_query_lib import QueryBuilder, QueryType
query = (
QueryBuilder(QueryType.SELECT)
.from_table("users")
.select_columns(["id", "name", "email"])
.where("age > %s", [18])
.set_limit(10)
.build()
)
print(query) # Output: SELECT id, name, email FROM users WHERE age > %s LIMIT 10
import asyncio
from natural_query_lib import QueryExecutor
async def main():
executor = QueryExecutor("postgresql://user:password@localhost:5432/mydb")
await executor.connect()
query = "SELECT * FROM users WHERE age > $1"
params = [18]
results = await executor.fetch(query, params)
for row in results:
print(dict(row))
await executor.close()
asyncio.run(main())
from natural_query_lib import QueryBuilder, QueryType
query_builder = (
QueryBuilder(QueryType.INSERT)
.from_table("users")
.values_json({
"name": "John Doe",
"email": "john@example.com",
"profile": {"age": 30, "location": "USA"}
})
)
query = query_builder.build()
params = query_builder.get_parameters()
print(query) # Output: INSERT INTO users (name, email, profile) VALUES (%s, %s, %s)
print(params) # Output: ["John Doe", "john@example.com", '{"age": 30, "location": "USA"}']
from natural_query_lib import QueryBuilder, QueryType, JoinType
query = (
QueryBuilder(QueryType.SELECT)
.from_table("orders o")
.select_columns(["o.id", "o.total", "u.name"])
.join(JoinType.INNER, "users u", "o.user_id = u.id")
.where("o.total > %s", [100])
.order_by_columns(["o.total DESC"])
.build()
)
print(
query) # Output: SELECT o.id, o.total, u.name FROM orders o INNER JOIN users u ON o.user_id = u.id WHERE o.total > %s ORDER BY o.total DESC
asyncpg
for high-performance database interactions.We welcome contributions to make Natural Query even better! Feel free to:
Natural Query is licensed under the MIT License. See the LICENSE file for details.
Happy coding! 🎉
FAQs
Flexible SQL query builder written in Python! This library allows you to build and execute SQL queries with ease, while supporting dynamic parameters and JSON encoding for database compatibility.
We found that natural-query-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.