All Projects → pypyodbc → pypyodbc

pypyodbc / pypyodbc

Licence: MIT license
pypyodbc is a pure Python cross platform ODBC interface module (pyodbc compatible as of 2017)

Programming Languages

python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to pypyodbc

sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (-23.08%)
Mutual labels:  sql-server, sqlserver
Monitor Table Change With Sqltabledependency
Get SQL Server notification on record table change
Stars: ✭ 459 (+1076.92%)
Mutual labels:  sql-server, sqlserver
OrdersManagementSystem
Project demonstrates usage of Prism composition library, Material design library, SQL Server, Entity Framework in WPF application
Stars: ✭ 29 (-25.64%)
Mutual labels:  sql-server, sqlserver
dbaTDPMon
dbaTDPMon - Troubleshoot Database Performance and Monitoring
Stars: ✭ 20 (-48.72%)
Mutual labels:  sql-server, sqlserver
Common
SQL FineBuild provides 1-click install and best-practice configuration on Windows of SQL Server 2019 through to SQL Server 2005
Stars: ✭ 32 (-17.95%)
Mutual labels:  sql-server, sqlserver
GraphQL.RepoDB
A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that enca…
Stars: ✭ 25 (-35.9%)
Mutual labels:  sql-server, sqlserver
Sqlpad
Web-based SQL editor run in your own private cloud. Supports MySQL, Postgres, SQL Server, Vertica, Crate, ClickHouse, Trino, Presto, SAP HANA, Cassandra, Snowflake, BigQuery, SQLite, and more with ODBC
Stars: ✭ 4,113 (+10446.15%)
Mutual labels:  sql-server, odbc
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+46484.62%)
Mutual labels:  sql-server, sqlserver
community-presentations
Presentation Repository for SQL Server / PowerShell Presentations within the Community
Stars: ✭ 38 (-2.56%)
Mutual labels:  sql-server, sqlserver
Syncchanges
Synchronize/Replicate database changes using SQL Server Change Tracking
Stars: ✭ 66 (+69.23%)
Mutual labels:  sql-server, sqlserver
tsql-scripts
Transact-SQL scripts and gists
Stars: ✭ 35 (-10.26%)
Mutual labels:  sql-server, sqlserver
SQLServerTools
This repo is the home of various SQL-Server-Tools
Stars: ✭ 28 (-28.21%)
Mutual labels:  sql-server, sqlserver
Freesql
🦄 .NET orm, Mysql orm, Postgresql orm, SqlServer orm, Oracle orm, Sqlite orm, Firebird orm, 达梦 orm, 人大金仓 orm, 神通 orm, 翰高 orm, 南大通用 orm, Click house orm, MsAccess orm.
Stars: ✭ 3,077 (+7789.74%)
Mutual labels:  odbc, sqlserver
mssql-restapi
A simple REST API for SQL Server, Azure SQL DB and Azure SQL DW using SMO on .NET Core 2.0
Stars: ✭ 33 (-15.38%)
Mutual labels:  sql-server, sqlserver
Nanodbc
A small C++ wrapper for the native C ODBC API | Requires C++14 since v2.12
Stars: ✭ 175 (+348.72%)
Mutual labels:  odbc, sqlserver
Mssqlex
Microsoft SQL Server Adapter for Elixir
Stars: ✭ 38 (-2.56%)
Mutual labels:  sql-server, odbc
r2dbc-migrate
R2DBC database migration tool & library
Stars: ✭ 83 (+112.82%)
Mutual labels:  sql-server, sqlserver
upscheme
Database migrations and schema updates made easy
Stars: ✭ 737 (+1789.74%)
Mutual labels:  sql-server, sqlserver
drift-server
Drift server
Stars: ✭ 19 (-51.28%)
Mutual labels:  sql-server
SSISMHash
SSIS Multiple Hash makes it possible to generate many Hash values from each input row. Hash's supported include MD5 and SHA1.
Stars: ✭ 32 (-17.95%)
Mutual labels:  sql-server

pypyodbc

A pure Python Cross Platform ODBC interface module

This is the new GitHub homepage of pypyodbc

Old repository was https://github.com/jiangwen365/pypyodbc/

Also check out the Wiki and Version History

Features

Simply try pypyodbc:

# Microsoft Access DB
import pypyodbc 

connection = pypyodbc.win_create_mdb('D:\\database.mdb')

SQL = 'CREATE TABLE saleout (id COUNTER PRIMARY KEY,product_name VARCHAR(25));'
connection.cursor().execute(SQL)
connection.close()
#SQL Server 2000/2005/2008 (and probably 2012 and 2014)
import pypyodbc as pyodbc # you could alias it to existing pyodbc code (not every code is compatible)
db_host = 'serverhost'
db_name = 'database'
db_user = 'username'
db_password = 'password'
connection_string = 'Driver={SQL Server};Server=' + db_host + ';Database=' + db_name + ';UID=' + db_user + ';PWD=' + db_password + ';'
db = pyodbc.connect(connection_string)
SQL = 'CREATE TABLE saleout (id COUNTER PRIMARY KEY,product_name VARCHAR(25));'
db.cursor().execute(SQL)

# Doing a simple SELECT query
connStr = (
    r'Driver={SQL Server};'
    r'Server=sqlserver;'
    #r'Server=127.0.0.1,52865;' +
    #r'Server=(local)\SQLEXPRESS;'
    r'Database=adventureworks;'
    #r'Trusted_Connection=Yes;'
    r'UID=sa;'
    r'PWD=sapassword;'
    )
db = pypyodbc.connect(connStr)
cursor = db.cursor()

# Sample with just a raw query:
cursor.execute("select client_name, client_lastname, [phone number] from Clients where client_id like '01-01-00%'")

# Using parameters (IMPORTANT: YOU SHOULD USE TUPLE TO PASS PARAMETERS)
# Python note: a tuple with just one element must have a trailing comma, otherwise is just a enclosed variable
cursor.execute("select client_name, client_lastname, [phone number] "
"from Clients where client_id like ?", ('01-01-00%', ))

# Sample, passing more than one parameter
cursor.execute("select client_name, client_lastname, [phone number] "
"from Clients where client_id like ? and client_age < ?", ('01-01-00%', 28))

# Method 1, simple reading using cursor
while True:
    row = cursor.fetchone()
    if not row:
        break
    print("Client Full Name (phone number): ", row['client_name'] + ' ' +  row['client_lastname'] + '(' + row['phone number'] + ')')

# Method 2, we obtain dict's all records are loaded at the same time in memory (easy and verbose, but just use it with a few records or your app will consume a lot of memory), was tested in a modern computer with about 1000 - 3000 records just fine...
import pprint; pp = pprint.PrettyPrinter(indent=4)
columns = [column[0] for column in cursor.description]
for row in cursor.fetchall():
    pp.pprint(dict(zip(columns, row)))

# Method 3, we obtain a list of dict's (represents the entire query)
query_results = [dict(zip([column[0] for column in cursor.description], row)) for row in cursor.fetchall()]
pp.pprint(query_results)

# When cursor was used must be closed, if you will not use again the db connection must be closed too.
cursor.close()
db.close()

How to use it without install (the latest version from here)

Just copy the latest pypyodbc.py downloaded from this repository on your project folder and import the module.

Install

If you have pip available (keep in mind that the version on pypi may be old):

pip install pypyodbc

Or get the latest pypyodbc.py script from GitHub (Main Development site) https://github.com/pypyodbc/pypyodbc

python setup.py install
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].