Cannot compile DropTable and CreateTable queries
See original GitHub issueHello!
I try to create table via this code:
import asyncio
from asyncpgsa import pg
import sqlalchemy as sa
from sqlalchemy.sql.ddl import CreateTable, DropTable
users = sa.Table(
'users', sa.MetaData(),
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('name', sa.VARCHAR(255)),
)
async def main():
await pg.init('postgresql://localhost/test')
await pg.query(DropTable(users))
await pg.query(CreateTable(users))
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
and got an error from asyncpgsa
Traceback (most recent call last):
File "/project/main.py", line 20, in <module>
loop.run_until_complete(main())
File "/project/.venv/python3.6/asyncio/base_events.py", line 467, in run_until_complete
return future.result()
File "/project/main.py", line 15, in main
await pg.query(DropTable(users))
File "/project/.venv/lib/python3.6/site-packages/asyncpgsa/pgsingleton.py", line 65, in query
compiled_q, compiled_args = compile_query(query)
File "/project/.venv/lib/python3.6/site-packages/asyncpgsa/connection.py", line 60, in compile_query
compiled_params = sorted(compiled.params.items())
AttributeError: 'NoneType' object has no attribute 'items'
Same code using sqlalchemy works fine:
import sqlalchemy as sa
from sqlalchemy.sql.ddl import CreateTable, DropTable
users = sa.Table(
'users', sa.MetaData(),
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('name', sa.VARCHAR(255)),
)
engine = sa.create_engine('postgresql://localhost/test')
engine.execute(DropTable(users))
engine.execute(CreateTable(users))
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Drop table, then cannot recreate table with the same name
You can't drop and create the same table in the same batch in sql server see MSDN. Their examples use GO to break...
Read more >SQL DROP TABLE statement overview
This article explores SQL DROP TABLE statement for dropping SQL Server table along with various use cases.
Read more >Can't create a table with the same name I deleted before
1 - Create table table_nome · 2 - Drop table table_nome · 3 - I'm trying to create a table with the same...
Read more >How to Use Create Table, Alter Table, and Drop Table in ...
An introduction to the create table, alter table, and drop table commands in Oracle Database. Use these to create, change, and remove ...
Read more >The Ultimate Guide to SQL Server DROP TABLE Statement
This tutorial shows you how to use the SQL Server DROP TABLE statement to remove one or more tables from a database.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has been merged and is in version 0.25.0
@nhumrich yeah, I’ve taken a closer look to the code of
connection.py
and decided to create my first GitHub PR 😉 #94 Please take a look at thatThis PR is related to the following issue https://github.com/CanopyTax/asyncpgsa/issues/59