Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for DDL expressions etc. #40

Closed
tomchristie opened this issue Feb 14, 2019 · 3 comments
Closed

Support for DDL expressions etc. #40

tomchristie opened this issue Feb 14, 2019 · 3 comments
Labels
feature New feature or request

Comments

@tomchristie
Copy link
Member

tomchristie commented Feb 14, 2019

Currently migrations and table creation is always performed using sync drivers.

At some point we might want to consider how we can properly integrate the async drivers all the way through, in order to have low-dependency installs, and in order to make sure we're using the same drivers both for migration operations and for regular interactions.

There's no performance reasons for doing so, but it'd be nice if we had comprehensive support for the full set of possible database operations.

@tomchristie tomchristie added the feature New feature or request label Feb 14, 2019
@pvanliefland
Copy link
Contributor

Are you thinking about a solution without SQLAlchemy / Alembic?

@tomchristie
Copy link
Member Author

Kinda. Eg. right now if test cases are using engine.create_all(), engine.drop_all() you're having to use a regular syncronous driver. That's fine but it means that we always have two sets of dependencies. An async database driver for the regular code, and a sync database driver for any migrations or table setup. It'd be nice if we didn't need to do that.

@tomchristie
Copy link
Member Author

Something like...

-    async def execute(self, query: ClauseElement) -> typing.Any:
+    async def execute(
+        self, query: typing.Union[ClauseElement, DDLElement]
+    ) -> typing.Any:
         assert self._connection is not None, "Connection is not acquired"
-        query, args, result_columns = self._compile(query)
-        return await self._connection.fetchval(query, *args)
+        if isinstance(query, DDLElement):
+            compiled = query.compile(dialect=self._dialect).string
+            await self._connection.execute(compiled)
+            return
+        else:
+            query, args, result_columns = self._compile(query)
+            return await self._connection.fetchval(query, *args)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants