alchimia Documentation

Similar documents
Essential SQLAlchemy. An Overview of SQLAlchemy. Rick Copeland Author, Essential SQLAlchemy Predictix, LLC

PART I SQLAlchemy Core

razi Documentation Release 2.0.0b0 Riccardo Vianello

INTRODUCTION TO DATABASES IN PYTHON. Creating Databases and Tables

Twisted is the first library we ll be working with that does not come with the Python Standard Library.

Connexion Sqlalchemy Utils Documentation

COMP 430 Intro. to Database Systems. SQL from application code

Database madness with & SQL Alchemy. Jaime Buelta. wrongsideofmemphis.worpress.com

Mixer Documentation. Release Kirill Klenov

wagtailtrans Documentation

This tutorial is designed for all those Python programmers who would like to understand the ORM framework with SQLAlchemy and its API.

ipython-gremlin Documentation

Runtime Dynamic Models Documentation Release 1.0

Setting up Caravel with IBM Big SQL

SQLAlchemy. EuroPython 2010

Papyrus Documentation

Flask-Migrate Documentation. Miguel Grinberg

Execute Server Actions from Client Methods

REXX/SQL for VM. User s Guide. Software Product Research

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

Python StatsD Documentation

phoenixdb Release Nov 14, 2017

Kuyruk Documentation. Release 0. Cenk Altı

File Depot Documentation

Graphene Documentation

sqlalchemy-redshift Documentation

Python AutoTask Web Services Documentation

pytest-benchmark Release 2.5.0

Watson - DB. Release 2.7.0

SQLAlchemy-Searchable Documentation

L6 Application Programming. Thibault Sellam Fall 2018

txzmq Documentation Release Andrey Smirnov

eventbrite-sdk-python Documentation

Crochet Documentation

Get Table Schema In Sql Server 2005 Modify. Column Size >>>CLICK HERE<<<

git-pr Release dev2+ng5b0396a

Torndb Release 0.3 Aug 30, 2017

Multicorn: writing foreign data wrappers in python. PostgreSQL Conference Europe 2013 Ronan Dunklau

Crochet Documentation

Friday, 11 April 14. Advanced methods for creating decorators Graham Dumpleton PyCon US - April 2014

PYTHON MYSQL DATABASE ACCESS

Top 50 JDBC Interview Questions and Answers

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

MongoTor Documentation

What is MariaDB 5.5? w: e: Daniel Bartholomew Oct 2012

PL/SQL Block structure

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

SQLAlchemy Session - In Depth

GitHub-Flask Documentation

Database Processing: Fundamentals, Design, and Implementation

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation

CSC Web Programming. Introduction to SQL

pymapd Documentation Release dev3+g4665ea7 Tom Augspurger

Microsoft. Microsoft Visual C# Step by Step. John Sharp

Perl Virtual Database Module

5. Single-row function

DOT NET Syllabus (6 Months)

doubles Documentation

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

UNIT III - JDBC Two Marks

Queries Documentation

nucleon Documentation

Oracle Database: Introduction to SQL

Call-back API. Polyhedra Ltd

CS 351 Design of Large Programs Singleton Pattern

CE419 Web Programming. Session 15: Django Web Framework

Question: Which statement would you use to invoke a stored procedure in isql*plus?

EXAMGOOD QUESTION & ANSWER. Accurate study guides High passing rate! Exam Good provides update free of charge in one year!

peewee-async Documentation

Seminar 4. Functions. Views. System tables

Canvas Data Utilities Documentation

PyMySQL Documentation

Java Enterprise Edition

Dobby Documentation. Release 0.1. Antoine Bertin

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL)

HIBERNATE MOCK TEST HIBERNATE MOCK TEST IV

Multicorn Documentation

Seven Awesome SQL Server Features

Pypeline Documentation

web frameworks design comparison draft - please help me improve it focus on Model-View-Controller frameworks

Oracle Database: Introduction to SQL/PLSQL Accelerated

A Quick Database Comparison of Db4o and SQL Databases through Cayenne

Oracle Database: Introduction to SQL

Get it done. One event at a time. How I learned to stop worrying and love EventMachine.

requests-cache Documentation

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger

Convention over Configuration

sqlalchemy-migrate Documentation

CS352 Lecture - Introduction to SQL

Block 3 The database language SQL. Block 3 The database language SQL. SQL Control Statements. SQL Control Statements. There are seven sections.

BIS Database Management Systems.

Crochet Documentation

MIS Database Systems.

HOW TO FLASK. And a very short intro to web development and databases

Oracle Database: Introduction to SQL

Snakemine: Redmine API wrapper Documentation

How Oracle Does It. No Read Locks

solrq Documentation Release Michał Jaworski

Microsoft Visual C# Step by Step. John Sharp

pyfirebirdsql documentation

Transcription:

alchimia Documentation Release Alex Gaynor and David Reid Mar 18, 2018

Contents 1 Getting started 3 2 Get the code 5 3 Contents 7 3.1 DDL................................................... 7 3.2 API Reference.............................................. 7 3.3 Limitations................................................ 10 3.4 Contributing............................................... 10 i

ii

alchimia Documentation, Release alchimia lets you use most of the SQLAlchemy-core API with Twisted, it does not allow you to use the ORM. Contents 1

alchimia Documentation, Release 2 Contents

CHAPTER 1 Getting started from alchimia import wrap_engine from sqlalchemy import ( create_engine, MetaData, Table, Column, Integer, String ) from sqlalchemy.schema import CreateTable from twisted.internet.defer import inlinecallbacks from twisted.internet.task import react @inlinecallbacks def main(reactor): engine = wrap_engine(reactor, create_engine("sqlite://")) metadata = MetaData() users = Table("users", metadata, Column("id", Integer(), primary_key=true), Column("name", String()), ) # Create the table yield engine.execute(createtable(users)) # Insert some users yield engine.execute(users.insert().values(name="jeremy Goodwin")) yield engine.execute(users.insert().values(name="natalie Hurley")) yield engine.execute(users.insert().values(name="dan Rydell")) yield engine.execute(users.insert().values(name="casey McCall")) yield engine.execute(users.insert().values(name="dana Whitaker")) result = yield engine.execute(users.select(users.c.name.startswith("d"))) d_users = yield result.fetchall() # Print out the users for user in d_users: 3

alchimia Documentation, Release print("username: %s" % user[users.c.name]) # Queries that return results should be explicitly closed to # release the connection result.close() if name == " main ": react(main, []) 4 Chapter 1. Getting started

CHAPTER 2 Get the code We re on github. Fork us! 5

alchimia Documentation, Release 6 Chapter 2. Get the code

CHAPTER 3 Contents 3.1 DDL Because of some of the limitations in the SQLAlchemy API, it s not possible to create tables using sqlalchemy. schema.table.create() or sqlalchemy.schema.metadata.create_all(). Luckily, SQLAlchemy provides an API that still makes it possible to create tables and perform other DDL operations. Instead of: users = Table("users", metadata, Column("id", Integer(), primary_key=true), Column("name", String()), ) users.create(engine) or metadata.create_all() You can use sqlalchemy.schema.createtable: from sqlalchemy.schema import CreateTable d = engine.execute(createtable(users)) 3.2 API Reference Many of these classes are missing methods from the SQLALchemy API. We encourage you to file bugs in those cases. alchimia.wrap_engine(reactor, engine, create_worker=...) This returns a alchimia.engine.twistedengine. 7

alchimia Documentation, Release The main entry-point to alchimia. To be used like so: from sqlalchemy import create_engine from alchimia import wrap_engine from twisted.internet import reactor underlying_engine = create_engine("sqlite://") twisted_engine = wrap_engine(reactor, engine) reactor - the Twisted reactor to use with the created TwistedEngine. engine - the underlying sqlalchemy.engine.engine create_worker - The object that will coordinate concurrent blocking work behind the scenes. The default implementation, if nothing is passed, is one which will use a threadpool where each Connection is tied to an individual thread. More precisely, this is a callable that is expected to return an object with 2 methods, do(work) (expected to call the 0-argument work callable in a thread), and quit(), expected to stop any future work from occurring. It may be useful to stub out the default threaded implementation for testing purposes. class alchimia.engine.twistedengine Mostly like sqlalchemy.engine.engine except some of the methods return Deferreds. init (pool, dialect, url, reactor=..., create_worker=...) This constructor is invoked if TwistedEngine is created via create_engine(..., reactor=reactor, strategy=twisted_strategy) rather than called directly. New applications should prefer alchimia.wrap_engine(). However, create_engine relays its keyword arguments, so the reactor and create_worker arguments have the same meaning as they do in alchimia.wrap_engine(). classmethod from_sqlalchemy_engine(reactor, engine, create_worker=...) This is the implementation of alchimia.wrap_engine. connect() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with a TwistedConnection. execute(*args, **kwargs) Like the SQLAlchemy method of the same name, except returns a Deferred which fires with a TwistedResultProxy. has_table(table_name, schema=none) Like the SQLAlchemy method of the same name, except returns a Deferred which fires with the result. table_names(schema=none, connection=none) Like the SQLAlchemy method of the same name, except returns a Deferred which fires with the result. class alchimia.engine.twistedconnection Mostly like sqlalchemy.engine.connection except some of the methods return Deferreds. execute(*args, **kwargs) Like the SQLAlchemy method of the same name, except returns a Deferred which fires with a TwistedResultProxy. close() Like the SQLAlchemy method of the same name, except returns a Deferred which fires when the connection has been closed. 8 Chapter 3. Contents

alchimia Documentation, Release closed Like the SQLAlchemy attribute of the same name. begin() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with a TwistedTransaction. begin_nested() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with a TwistedTransaction. in_transaction() Like the SQLAlchemy method of the same name. class alchimia.engine.twistedtransaction Mostly like sqlalchemy.engine.transaction except some of the methods return Deferreds. commit() Like the SQLAlchemy method of the same name, except returns a Deferred which fires when the transaction has been committed. rollback() Like the SQLAlchemy method of the same name, except returns a Deferred which fires when the transaction has been rolled back. closed() Like the SQLAlchemy method of the same name, except returns a Deferred which fires when the transaction has been closed. class alchimia.engine.twistedresultproxy Mostly like sqlalchemy.engine.resultproxy except some of the methods return Deferreds. fetchone() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with a row. fetchall() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with a list of rows. scalar() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with the scalar value. first() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with the scalar value. keys() Like the SQLAlchemy method of the same name, except returns a Deferred which fires with the scalar value. close() Like the SQLAlchemy method of the same name, it releases the resources used and releases the underlying DB connection. returns_rows Like the SQLAlchemy attribute of the same name. rowcount Like the SQLAlchemy attribute of the same name. 3.2. API Reference 9

alchimia Documentation, Release inserted_primary_key Like the SQLAlchemy attribute of the same name. 3.3 Limitations There are two reasons stuff isn t implemented in alchimia. First, because we haven t gotten there yet. For these items you should file bugs or send pull requests. Second, some items can t be implemented because of limitations in SQLAlchemy, there s almost always a workaround though. Table creation 3.4 Contributing As an open source project, Alchimia welcomes contributions of many forms. Examples of contributions include: Code patches Documentation improvements Bug reports and patch reviews We welcome pull requests and tickets on github! 10 Chapter 3. Contents

Index Symbols init () (alchimia.engine.twistedengine method), 8 B begin() (alchimia.engine.twistedconnection method), 9 begin_nested() (alchimia.engine.twistedconnection method), 9 C close() (alchimia.engine.twistedconnection method), 8 close() (alchimia.engine.twistedresultproxy method), 9 closed (alchimia.engine.twistedconnection attribute), 8 closed() (alchimia.engine.twistedtransaction method), 9 commit() (alchimia.engine.twistedtransaction method), 9 connect() (alchimia.engine.twistedengine method), 8 E execute() (alchimia.engine.twistedconnection method), 8 execute() (alchimia.engine.twistedengine method), 8 F fetchall() (alchimia.engine.twistedresultproxy method), 9 fetchone() (alchimia.engine.twistedresultproxy method), 9 first() (alchimia.engine.twistedresultproxy method), 9 from_sqlalchemy_engine() (alchimia.engine.twistedengine class method), 8 H has_table() (alchimia.engine.twistedengine method), 8 I in_transaction() (alchimia.engine.twistedconnection method), 9 inserted_primary_key (alchimia.engine.twistedresultproxy attribute), 9 K keys() (alchimia.engine.twistedresultproxy method), 9 R returns_rows (alchimia.engine.twistedresultproxy attribute), 9 rollback() (alchimia.engine.twistedtransaction method), 9 rowcount (alchimia.engine.twistedresultproxy attribute), 9 S scalar() (alchimia.engine.twistedresultproxy method), 9 T table_names() (alchimia.engine.twistedengine method), 8 TwistedConnection (class in alchimia.engine), 8 TwistedEngine (class in alchimia.engine), 8 TwistedResultProxy (class in alchimia.engine), 9 TwistedTransaction (class in alchimia.engine), 9 W wrap_engine() (in module alchimia), 7 11