SQLAlchemy-Easy-Connection
Simple way to connect Database using SQLAlchemy.
Project motivations
This repository makes use of trivial options in the creation of the database engine. My intention is to facilitate the connection to the database using SQLAlchemy, distributing this package that I created and use many years ago, I intend over time to add standard options for each type of database, making only you worry about connecting to the database.
Suggestions, improvements and contact, I am available at email: 'marcus.paiva.ti@gmail.com'.
How to install?
You can install using the following command:
pip install SQLAlchemy-Easy-Connection
Simple usage example
from SQLAlchemyEasyConnection.EasyConnections import EasyConnection # Using this package we use to connect into database
from SQLAlchemyEasyConnection import DatabaseTypes # This file is easy way to get you SQL server name
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
db_connection = EasyConnection() # Instance
db_connection.connect_to_database(type_database=DatabaseTypes.SQLITE,
database="C:\\temp\\sqltest.db") # Create Connection to database
# Using declarative base
Base = declarative_base()
# This class is a simple example to create using SQLAlchemy
class User(Base):
__tablename__ = "user"
id_user = Column(Integer, primary_key=True)
name = Column(String)
email = Column(String)
Base.metadata.create_all(db_connection.get_engine) # Create table
# Creating a new user using ORM
user = User()
user.name = "foo"
user.email = "foo@bar.com"
# Add new User
db_connection.insert_item(user)
db_connection.session_commit()
print(user.id_user) # see? This show new user ID after create a new user in table 'user'
Metadata
Release files for SQLAlchemy-Easy-Connection-0.0.2 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| SQLAlchemy-Easy-Connection-0.0.2-0.0.2.tar.gz | 4.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| SQLAlchemy_Easy_Connection_0.0.2-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / SQLAlchemy-Easy-Connection-0.0.2-0.0.2.tar.gz
| Download URL | SQLAlchemy-Easy-Connection-0.0.2-0.0.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cf2d535f8cec5b83d88d295ae40724f66fd5bdfcb5bdd934dd4d9e90f62da27
|
|
BLAKE2b-256 checksum How to use checksums |
592fa4692c9965eba04961dce5a4138092b15c42daeaf6a061603982a0a5df04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.8
|
Release files / SQLAlchemy_Easy_Connection_0.0.2-0.0.2-py3-none-any.whl
| Download URL | SQLAlchemy_Easy_Connection_0.0.2-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47981493cd99c303fd354ce96281437a15a900909c9d4c8b0a774f72918c7b7e
|
|
BLAKE2b-256 checksum How to use checksums |
e1873052fbb27d6cd2806fdbf09220dbe478d065303147eb09db48391239ae67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.8
|