• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

alchimia

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

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:
        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, [])

Documentation

The documentation is all on Read the Docs.

Limitations

There are some limitations to alchimia's ability to expose the SQLAlchemy API.

  • Some methods simply haven't been implemented yet. If you file a bug, we'll implement them! See CONTRIBUTING.rst for more info.
  • Some methods in SQLAlchemy either have no return value, or don't have a return value we can control. Since most of the alchimia API is predicated on returning Deferred instances which fire with the underlying SQLAlchemy instances, it is impossible for us to wrap these methods in a useful way. Luckily, many of these methods have alternate spelling. The docs call these out in more detail.

More Repositories

1

what-happens-when

An attempt to answer the age old interview question "What happens when you type google.com into your browser and press enter?"
39,628
star
2

nyt-2020-election-scraper

HTML
1,761
star
3

letsencrypt-aws

Python
729
star
4

rply

An attempt to port David Beazley's PLY to RPython, and give it a cooler API.
Python
377
star
5

pretend

A library for stubbing in python
Python
290
star
6

django-ajax-validation

A reusable application to preform ajax validation on django forms.
Python
252
star
7

django-templatetag-sugar

This project exists to make defining template tags in Django kickass
Python
213
star
8

ecs-terraform

ECS + Terraform = Crazy delicious
HCL
203
star
9

csv-sql

Query your CSV files with SQL
Rust
192
star
10

django-fixture-generator

django-fixture-generator is a reusable django application to make writing fixtures not suck.
Python
138
star
11

zero_buffer

zero_buffer is a high-performance, zero-copy, implementation of a byte-buffer for Python.
Python
136
star
12

pyvcs

A pure python abstraction layer of multiple VCS, very lightweight.
Python
128
star
13

django-admin-histograms

A library for simple histograms in Django's admin.
Python
106
star
14

rust-asn1

A Rust ASN.1 (DER) serializer.
Rust
99
star
15

django-vcs

A django application for working with a VCS, analagous to some of Trac's features.
Python
86
star
16

just-use

Just Use /dev/urandom -- now with more safety at early boot
Rust
60
star
17

django-wsgi

A library for better integration between django and the WSGI world.
Python
49
star
18

python-decompiler

A decompiler for CPython bytecode
Python
48
star
19

piano-man

Python
44
star
20

django-project-skeleton

A skeleton for Django 1.4's new project template support.
Python
41
star
21

django-resume-builder

Python
36
star
22

line-counter

Like `wc -l`, but in Rust and maybe faster
Rust
29
star
23

django-plugins

A generic plugin system for django.
Python
28
star
24

otp-cop

Tooling for verifying that everyone in your orgs has 2fa enabled.
Rust
28
star
25

nba-gamethread

A game thread generator for r/nba
Python
26
star
26

vcs-translator

Python
25
star
27

bagel

Bagels are delicious
Python
22
star
28

Shore

A statically typed programming language with inspiration from C++, Python, and others.
Python
19
star
29

ct-tools

Some Rust code for submitting a cert to all of Chrome's trusted CT logs and getting back the SCTs
Rust
17
star
30

x509-validator

A pure-Python x509 validation library based on pyca/cryptography
Python
16
star
31

httpfuzz

Python
13
star
32

tracebin

The ultimate performance command and control center for PyPy.
Python
12
star
33

django-object-cache

A reusable django object cache.
12
star
34

tls-stats

A webExtension to collect TLS stats
JavaScript
11
star
35

pyelection

A python application for following the US primaries
Python
10
star
36

recipes

My Recipes
Python
10
star
37

ex-post-progress

Rust
9
star
38

evolves

A Python implementation of a genetic algorithm for generating images from polygons
Python
9
star
39

doc-extractor

Go
8
star
40

tls-cal

Python
8
star
41

election-sim

An application for following and simulating the 2008 US Presidential Election.
Python
7
star
42

alex-s-language

Inteded to be a compiled Python, by translating source files to C++
Python
7
star
43

optimizer-model

A work in progress model for a new optimizer for PyPy's JIT.
Python
7
star
44

http-client-bench

Python
7
star
45

revocation-tracker

Python
7
star
46

flickr-avatars

a small webservice to make getting flickr users' avatars
Python
6
star
47

yaffi

Yet Another FFI
Python
6
star
48

json_writer

Python
5
star
49

rdio-export

JavaScript
4
star
50

space-hogs

A game made in python with pyglet.
Python
4
star
51

csv-to-parquet

Go
3
star
52

independent-study-tracebin

Documentation for my independent study on tracebin
Python
3
star
53

montgomery-ladder-go

An implementation of modular exponentiation using the montgomery ladder in Go.
Go
2
star
54

api-serializer

Random hack, don't use.
Python
2
star
55

azure-pipelines-docker-test

2
star
56

win32k-stuff

JavaScript
2
star
57

client-beta

Go
2
star
58

temp-rust-coverage

Rust
1
star
59

doc8

Python
1
star
60

temp-gha-macos-python

1
star
61

botan-fuzzers

Fuzzer instrumentation for botan
C++
1
star