Skip to main content

autosql

一键生成SQL脚本

支持的数据库

Oracle; MySQL; PostgreSQL

支持的操作

建表;建索引;删除表

安装

    pip install autosql

使用

    # test.py
    from autosql import autosql

    obj = autosql.get("path\to\excel\", file_name, dbtype, ifdrop, transform)
    obj.create_table()
    obj.create_index()
    obj.drop_table()

autosql.get()

参数:

  1. path: excel文件路径

  2. file_name: excel文件名

  3. dbtype: 数据库

  4. ifdrop: 是否生成drop语句

  5. transform: 是否进行格式转换

EXCEL格式规范

sheets

  1. 目录

     结构:
     
     中文名 | 表名 | 是否生成脚本 | 日期分区
     测试表 | Test | 1           | 0
    
  2. 索引

     示例:
     表名 | 索引列   | 是否主键 | 是否唯一索引 | 是否有效
     Test | isValid | 0       | 0           | 1
    
  3. Test(表名)

     示例:
     字段     | 含义  | 类型 | 非空 | 默认值 | 键          | 扩展
     id       | 标识 | int  | 是   |        | primary key | auto_increment
     initdate | 时间 | Date | 是   | now()  |             |   
    

函数

表中的函数、数据类型、扩展等都默认为mysql格式,或者你可以自行填写,然后将格式转换设置为False,前提是你确保填写正确

    transform = False

Metadata

Release files for autosql 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autosql 1.0.0
File Size Uploaded
autosql-1.0.0.tar.gz 5.2 kB Details

Release files / autosql-1.0.0.tar.gz

Download URL autosql-1.0.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b53c36e79ee217602f85999ed0a2b852869a4a590168937724b8c661e5f5e159
BLAKE2b-256 checksum
How to use checksums
f4f9e6ed92e6a955b67b2fe8e2be212c11dcdf830beda622a466468bea9d1250
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page