Skip to content

Commit b48e6cb

Browse files
committed
Initial commit.
0 parents  commit b48e6cb

File tree

9 files changed

+915
-0
lines changed

9 files changed

+915
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sqlalchemy_pervasive.egg-info

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
0.1.0
3+
-----
4+
5+
* Initial version.

COPYING.txt

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
sqlalchemy-pervasive
3+
====================
4+
5+
A SQLAlchemy dialect for the `Pervasive PSQL`_ database engine.
6+
7+
.. _Pervasive PSQL: http://www.pervasive.com/database/

setup.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
################################################################################
4+
#
5+
# sqlalchemy-pervasive -- SQLAlchemy Dialect for Pervasive PSQL
6+
# Copyright © 2013 Lance Edgar
7+
#
8+
# This file is part of sqlalchemy-pervasive.
9+
#
10+
# sqlalchemy-pervasive is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by the
12+
# Free Software Foundation, either version 3 of the License, or (at your
13+
# option) any later version.
14+
#
15+
# sqlalchemy-pervasive is distributed in the hope that it will be useful, but
16+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17+
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18+
# more details.
19+
#
20+
# You should have received a copy of the GNU General Public License along with
21+
# sqlalchemy-pervasive. If not, see <http://www.gnu.org/licenses/>.
22+
#
23+
################################################################################
24+
25+
26+
import os.path
27+
from setuptools import setup, find_packages
28+
29+
30+
here = os.path.abspath(os.path.dirname(__file__))
31+
execfile(os.path.join(here, 'sqlalchemy_pervasive', '_version.py'))
32+
33+
README = open(os.path.join(here, 'README.txt')).read()
34+
CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
35+
36+
37+
requires = [
38+
#
39+
# Version numbers within comments below have specific meanings.
40+
# Basically the 'low' value is a "soft low," and 'high' a "soft high."
41+
# In other words:
42+
#
43+
# If either a 'low' or 'high' value exists, the primary point to be
44+
# made about the value is that it represents the most current (stable)
45+
# version available for the package (assuming typical public access
46+
# methods) whenever this project was started and/or documented.
47+
# Therefore:
48+
#
49+
# If a 'low' version is present, you should know that attempts to use
50+
# versions of the package significantly older than the 'low' version
51+
# may not yield happy results. (A "hard" high limit may or may not be
52+
# indicated by a true version requirement.)
53+
#
54+
# Similarly, if a 'high' version is present, and especially if this
55+
# project has laid dormant for a while, you may need to refactor a bit
56+
# when attempting to support a more recent version of the package. (A
57+
# "hard" low limit should be indicated by a true version requirement
58+
# when a 'high' version is present.)
59+
#
60+
# In any case, developers and other users are encouraged to play
61+
# outside the lines with regard to these soft limits. If bugs are
62+
# encountered then they should be filed as such.
63+
#
64+
# package # low high
65+
66+
'pyodbc', # 2.1.11
67+
'SQLAlchemy', # 0.8.2
68+
]
69+
70+
71+
setup(
72+
name = "sqlalchemy-pervasive",
73+
version = __version__,
74+
author = "Lance Edgar",
75+
author_email = "lance@edbob.org",
76+
license = "GNU GPL v3",
77+
description = "SQLAlchemy Dialect for Pervasive PSQL",
78+
long_description = README + '\n\n' + CHANGES,
79+
80+
classifiers = [
81+
'Development Status :: 3 - Alpha',
82+
'Intended Audience :: Developers',
83+
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
84+
'Natural Language :: English',
85+
'Operating System :: OS Independent',
86+
'Programming Language :: Python',
87+
'Programming Language :: Python :: 2.6',
88+
'Programming Language :: Python :: 2.7',
89+
'Topic :: Software Development :: Libraries :: Python Modules',
90+
],
91+
92+
install_requires = requires,
93+
packages = find_packages(),
94+
include_package_data = True,
95+
96+
entry_points = """
97+
98+
[sqlalchemy.dialects]
99+
pervasive = sqlalchemy_pervasive.pyodbc:PervasiveDialect_pyodbc
100+
101+
""",
102+
)

sqlalchemy_pervasive/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
################################################################################
4+
#
5+
# sqlalchemy-pervasive -- SQLAlchemy Dialect for Pervasive PSQL
6+
# Copyright © 2013 Lance Edgar
7+
#
8+
# This file is part of sqlalchemy-pervasive.
9+
#
10+
# sqlalchemy-pervasive is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by the
12+
# Free Software Foundation, either version 3 of the License, or (at your
13+
# option) any later version.
14+
#
15+
# sqlalchemy-pervasive is distributed in the hope that it will be useful, but
16+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17+
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18+
# more details.
19+
#
20+
# You should have received a copy of the GNU General Public License along with
21+
# sqlalchemy-pervasive. If not, see <http://www.gnu.org/licenses/>.
22+
#
23+
################################################################################
24+
25+
26+
from ._version import __version__
27+
28+
from sqlalchemy.dialects import registry
29+
30+
31+
registry.register('pervasive', 'sqlalchemy_pervasive.pyodbc', 'PervasiveDialect_pyodbc')

sqlalchemy_pervasive/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.1.0'

sqlalchemy_pervasive/base.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
################################################################################
4+
#
5+
# sqlalchemy-pervasive -- SQLAlchemy Dialect for Pervasive PSQL
6+
# Copyright © 2013 Lance Edgar
7+
#
8+
# This file is part of sqlalchemy-pervasive.
9+
#
10+
# sqlalchemy-pervasive is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by the
12+
# Free Software Foundation, either version 3 of the License, or (at your
13+
# option) any later version.
14+
#
15+
# sqlalchemy-pervasive is distributed in the hope that it will be useful, but
16+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17+
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18+
# more details.
19+
#
20+
# You should have received a copy of the GNU General Public License along with
21+
# sqlalchemy-pervasive. If not, see <http://www.gnu.org/licenses/>.
22+
#
23+
################################################################################
24+
25+
"""
26+
Support for the Pervasive PSQL database engine.
27+
"""
28+
29+
from sqlalchemy.sql.compiler import SQLCompiler
30+
from sqlalchemy.engine.default import DefaultDialect
31+
from sqlalchemy.exc import InvalidRequestError
32+
33+
34+
class PervasiveCompiler(SQLCompiler):
35+
"""
36+
Custom SQL statement compiler for Pervasive PSQL.
37+
"""
38+
39+
# This logic was basically copied from the ``sqlalchemy-access`` dialect.
40+
41+
def get_select_precolumns(self, select):
42+
s = 'DISTINCT ' if select._distinct else ''
43+
if select._limit:
44+
s += 'TOP {0} '.format(select._limit)
45+
if select._offset:
46+
raise InvalidRequestError(
47+
"Pervasive PSQL does not support TOP (limit) with an offset")
48+
return s
49+
50+
def limit_clause(self, select):
51+
return ""
52+
53+
54+
class PervasiveDialect(DefaultDialect):
55+
56+
name = 'pervasive'
57+
58+
statement_compiler = PervasiveCompiler

sqlalchemy_pervasive/pyodbc.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
################################################################################
4+
#
5+
# sqlalchemy-pervasive -- SQLAlchemy Dialect for Pervasive PSQL
6+
# Copyright © 2013 Lance Edgar
7+
#
8+
# This file is part of sqlalchemy-pervasive.
9+
#
10+
# sqlalchemy-pervasive is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by the
12+
# Free Software Foundation, either version 3 of the License, or (at your
13+
# option) any later version.
14+
#
15+
# sqlalchemy-pervasive is distributed in the hope that it will be useful, but
16+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17+
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18+
# more details.
19+
#
20+
# You should have received a copy of the GNU General Public License along with
21+
# sqlalchemy-pervasive. If not, see <http://www.gnu.org/licenses/>.
22+
#
23+
################################################################################
24+
25+
"""
26+
Support for Pervasive PSQL via ``pyodbc``.
27+
"""
28+
29+
from sqlalchemy.connectors.pyodbc import PyODBCConnector
30+
31+
from .base import PervasiveDialect
32+
33+
34+
class PervasiveDialect_pyodbc(PyODBCConnector, PervasiveDialect):
35+
36+
pass

0 commit comments

Comments
 (0)