How to create permanent MS Access Query by Python 3.5.1?

前端 未结 2 1783
小鲜肉
小鲜肉 2021-01-20 23:35

I have about 40 MS Access Databases and have some troubles if need to create or transfer one of MS Access Query (like object) from one db to other dbs. So I tried to solve this

2条回答
  •  Happy的楠姐
    2021-01-21 00:05

    You can use a CREATE VIEW statement to create a saved Select Query in Access. The pyodbc equivalent to your VBA example would be

    crsr = conn.cursor()
    sql = """\
    CREATE VIEW TestQuery AS
    SELECT * FROM TestTable
    """
    crsr.execute(sql)
    

    To delete that saved query you could simply execute a DROP VIEW statement.

    For more information on DDL in Access see

    Data Definition Language

提交回复
热议问题