Skip to main content

Simple way to connect Database using SQLAlchemy.

Project description

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'

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

SQLAlchemy-Easy-Connection-0.0.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SQLAlchemy_Easy_Connection-0.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file SQLAlchemy-Easy-Connection-0.0.2.tar.gz.

File metadata

  • Download URL: SQLAlchemy-Easy-Connection-0.0.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for SQLAlchemy-Easy-Connection-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c4967049d6f51e4958de91c47952ae0451b45761d579802fda7147324780d95f
MD5 cb2925e79e30569e9c6e65ca8e583ff2
BLAKE2b-256 e1c601c976bc9e673c326b4f4e2d03989bb6b7eacefca6c4efa4f4a4bf484ad0

See more details on using hashes here.

File details

Details for the file SQLAlchemy_Easy_Connection-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: SQLAlchemy_Easy_Connection-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for SQLAlchemy_Easy_Connection-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5fe7faec0fe266898b811129e9f770f8b7252fa2d165c26333fa364376be08e7
MD5 7d223ebad0fbfcc8dad971ec95ec222e
BLAKE2b-256 70f2d33a5c361019c760cb38b098e965d1a3ef3f1ad8e7da558b9eaa76248585

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page