當前位置: 首頁>>代碼示例>>Python>>正文


Python sqlalchemy.TEXT屬性代碼示例

本文整理匯總了Python中sqlalchemy.TEXT屬性的典型用法代碼示例。如果您正苦於以下問題:Python sqlalchemy.TEXT屬性的具體用法?Python sqlalchemy.TEXT怎麽用?Python sqlalchemy.TEXT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在sqlalchemy的用法示例。


在下文中一共展示了sqlalchemy.TEXT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _transaction_test

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def _transaction_test(self):
        self.pandasSQL.execute("CREATE TABLE test_trans (A INT, B TEXT)")

        ins_sql = "INSERT INTO test_trans (A,B) VALUES (1, 'blah')"

        # Make sure when transaction is rolled back, no rows get inserted
        try:
            with self.pandasSQL.run_transaction() as trans:
                trans.execute(ins_sql)
                raise Exception('error')
        except Exception:
            # ignore raised exception
            pass
        res = self.pandasSQL.read_query('SELECT * FROM test_trans')
        assert len(res) == 0

        # Make sure when transaction is committed, rows do get inserted
        with self.pandasSQL.run_transaction() as trans:
            trans.execute(ins_sql)
        res2 = self.pandasSQL.read_query('SELECT * FROM test_trans')
        assert len(res2) == 1


# -----------------------------------------------------------------------------
# -- Testing the public API 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:27,代碼來源:test_sql.py

示例2: test_execute_fail

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def test_execute_fail(self):
        create_sql = """
        CREATE TABLE test
        (
        a TEXT,
        b TEXT,
        c REAL,
        PRIMARY KEY (a, b)
        );
        """
        cur = self.conn.cursor()
        cur.execute(create_sql)

        sql.execute('INSERT INTO test VALUES("foo", "bar", 1.234)', self.conn)
        sql.execute('INSERT INTO test VALUES("foo", "baz", 2.567)', self.conn)

        with pytest.raises(Exception):
            sql.execute('INSERT INTO test VALUES("foo", "bar", 7)', self.conn) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:20,代碼來源:test_sql.py

示例3: test_execute_closed_connection

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def test_execute_closed_connection(self):
        create_sql = """
        CREATE TABLE test
        (
        a TEXT,
        b TEXT,
        c REAL,
        PRIMARY KEY (a, b)
        );
        """
        cur = self.conn.cursor()
        cur.execute(create_sql)

        sql.execute('INSERT INTO test VALUES("foo", "bar", 1.234)', self.conn)
        self.conn.close()

        with pytest.raises(Exception):
            tquery("select * from test", con=self.conn) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:20,代碼來源:test_sql.py

示例4: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('nu_outbound_wrappers', sa.Column('target_url', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('nu_outbound_wrappers', sa.Column('link_url', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('nu_outbound_wrappers', sa.Column('container_page', sa.TEXT(), autoincrement=False, nullable=True))
    op.create_index('ix_nu_outbound_wrappers_link_url', 'nu_outbound_wrappers', ['link_url'], unique=False)
    op.create_index('ix_nu_outbound_wrappers_container_page', 'nu_outbound_wrappers', ['container_page'], unique=False)
    op.drop_index(op.f('ix_nu_outbound_wrappers_seriesname'), table_name='nu_outbound_wrappers')
    op.drop_index(op.f('ix_nu_outbound_wrappers_groupinfo'), table_name='nu_outbound_wrappers')
    op.drop_index(op.f('ix_nu_outbound_wrappers_client_key'), table_name='nu_outbound_wrappers')
    op.drop_index(op.f('ix_nu_outbound_wrappers_client_id'), table_name='nu_outbound_wrappers')
    op.drop_column('nu_outbound_wrappers', 'seriesname')
    op.drop_column('nu_outbound_wrappers', 'releaseinfo')
    op.drop_column('nu_outbound_wrappers', 'referrer')
    op.drop_column('nu_outbound_wrappers', 'outbound_wrapper')
    op.drop_column('nu_outbound_wrappers', 'groupinfo')
    op.drop_column('nu_outbound_wrappers', 'client_key')
    op.drop_column('nu_outbound_wrappers', 'client_id')
    op.drop_column('nu_outbound_wrappers', 'actual_target')
    ### end Alembic commands ### 
開發者ID:fake-name,項目名稱:ReadableWebProxy,代碼行數:22,代碼來源:00007_cb674b790e4a_more_nu_stuff.py

示例5: upgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('rss_parser_feed_name_lut', sa.Column('feed_id', sa.BigInteger(), nullable=False))
    op.create_index(op.f('ix_rss_parser_feed_name_lut_feed_id'), 'rss_parser_feed_name_lut', ['feed_id'], unique=False)
    op.drop_index('ix_rss_parser_feed_name_lut_feed_name', table_name='rss_parser_feed_name_lut')
    op.drop_constraint('rss_parser_feed_name_lut_feed_netloc_feed_name_key', 'rss_parser_feed_name_lut', type_='unique')
    op.create_unique_constraint(None, 'rss_parser_feed_name_lut', ['feed_netloc', 'feed_id'])
    op.drop_constraint('rss_parser_feed_name_lut_feed_name_fkey', 'rss_parser_feed_name_lut', type_='foreignkey')
    op.create_foreign_key(None, 'rss_parser_feed_name_lut', 'rss_parser_funcs', ['feed_id'], ['id'])
    op.drop_column('rss_parser_feed_name_lut', 'feed_name')
    op.add_column('rss_parser_feed_name_lut_version', sa.Column('feed_id', sa.BigInteger(), autoincrement=False, nullable=True))
    op.create_index(op.f('ix_rss_parser_feed_name_lut_version_feed_id'), 'rss_parser_feed_name_lut_version', ['feed_id'], unique=False)
    op.drop_index('ix_rss_parser_feed_name_lut_version_feed_name', table_name='rss_parser_feed_name_lut_version')
    op.drop_column('rss_parser_feed_name_lut_version', 'feed_name')
    op.alter_column('rss_parser_funcs', 'func',
               existing_type=sa.TEXT(),
               nullable=True)
    ### end Alembic commands ### 
開發者ID:fake-name,項目名稱:ReadableWebProxy,代碼行數:20,代碼來源:00027_c92e0c8632d7_more_rss_stuff.py

示例6: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('feed_pages', sa.Column('feedurl', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('feed_pages', sa.Column('srcname', sa.TEXT(), autoincrement=False, nullable=True))
    op.create_table('nu_outbound_wrappers',
    sa.Column('id', sa.BIGINT(), nullable=False),
    sa.Column('actual_target', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('client_id', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('client_key', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('groupinfo', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('outbound_wrapper', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('referrer', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('releaseinfo', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('seriesname', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('validated', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('released_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='nu_outbound_wrappers_pkey'),
    sa.UniqueConstraint('client_id', 'client_key', 'seriesname', 'releaseinfo', 'groupinfo', 'actual_target', name='nu_outbound_wrappers_client_id_client_key_seriesname_releas_key')
    )
    ### end Alembic commands ### 
開發者ID:fake-name,項目名稱:ReadableWebProxy,代碼行數:22,代碼來源:00030_be0687950ece_actually_dropping_unused_columns_now.py

示例7: _transaction_test

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def _transaction_test(self):
        self.pandasSQL.execute("CREATE TABLE test_trans (A INT, B TEXT)")

        ins_sql = "INSERT INTO test_trans (A,B) VALUES (1, 'blah')"

        # Make sure when transaction is rolled back, no rows get inserted
        try:
            with self.pandasSQL.run_transaction() as trans:
                trans.execute(ins_sql)
                raise Exception('error')
        except:
            # ignore raised exception
            pass
        res = self.pandasSQL.read_query('SELECT * FROM test_trans')
        assert len(res) == 0

        # Make sure when transaction is committed, rows do get inserted
        with self.pandasSQL.run_transaction() as trans:
            trans.execute(ins_sql)
        res2 = self.pandasSQL.read_query('SELECT * FROM test_trans')
        assert len(res2) == 1


# -----------------------------------------------------------------------------
# -- Testing the public API 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:27,代碼來源:test_sql.py

示例8: test_execute_closed_connection

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def test_execute_closed_connection(self, request, datapath):
        create_sql = """
        CREATE TABLE test
        (
        a TEXT,
        b TEXT,
        c REAL,
        PRIMARY KEY (a, b)
        );
        """
        cur = self.conn.cursor()
        cur.execute(create_sql)

        sql.execute('INSERT INTO test VALUES("foo", "bar", 1.234)', self.conn)
        self.conn.close()

        with pytest.raises(Exception):
            tquery("select * from test", con=self.conn)

        # Initialize connection again (needed for tearDown)
        self.setup_method(request, datapath) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:23,代碼來源:test_sql.py

示例9: test_execute_closed_connection

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def test_execute_closed_connection(self):
        create_sql = """
        CREATE TABLE test
        (
        a TEXT,
        b TEXT,
        c REAL,
        PRIMARY KEY (a, b)
        );
        """
        cur = self.conn.cursor()
        cur.execute(create_sql)

        sql.execute('INSERT INTO test VALUES("foo", "bar", 1.234)', self.conn)
        self.conn.close()

        with pytest.raises(Exception):
            tquery("select * from test", con=self.conn)

        # Initialize connection again (needed for tearDown)
        self.setup_method(self.method) 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:23,代碼來源:test_sql.py

示例10: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('guild_members',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('guild_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('user_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('username', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('discriminator', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('nickname', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('avatar', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('active', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False),
    sa.Column('banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
    sa.Column('roles', sa.TEXT(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id', name='idx_25210_primary')
    )
    # ### end Alembic commands ### 
開發者ID:TitanEmbeds,項目名稱:Titan,代碼行數:18,代碼來源:1d2c2dc41e86_removed_guild_members_table.py

示例11: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('messages',
    sa.Column('guild_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('channel_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('message_id', sa.BIGINT(), autoincrement=False, nullable=False),
    sa.Column('content', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('author', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('edited_timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('mentions', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('attachments', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('embeds', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('message_id', name='messages_pkey')
    )
    # ### end Alembic commands ### 
開發者ID:TitanEmbeds,項目名稱:Titan,代碼行數:18,代碼來源:52271b243ba2_remove_messages_table_for_good.py

示例12: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('departments', sa.Column('what_this_is', sa.TEXT(), autoincrement=False, nullable=True))
    ### end Alembic commands ### 
開發者ID:codeforamerica,項目名稱:comport,代碼行數:6,代碼來源:529cc76baaa_.py

示例13: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('departments', sa.Column('why_we_are_doing_this', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('departments', sa.Column('contact_us', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('departments', sa.Column('how_you_can_use_this_data', sa.TEXT(), autoincrement=False, nullable=True))
    ### end Alembic commands ### 
開發者ID:codeforamerica,項目名稱:comport,代碼行數:8,代碼來源:a6192071a8_.py

示例14: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('chart_block_defaults',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('title', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('caption', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
    sa.Column('slug', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('dataset', sa.VARCHAR(length=255), autoincrement=False, nullable=False),
    sa.Column('content', sa.TEXT(), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='chart_block_defaults_pkey')
    )
    ### end Alembic commands ### 
開發者ID:codeforamerica,項目名稱:comport,代碼行數:14,代碼來源:4e4710949dd_.py

示例15: downgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TEXT [as 別名]
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('task_result', sa.Column('traceback', sa.TEXT(), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('task_id', sa.VARCHAR(length=155), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('date_done', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('status', sa.VARCHAR(length=50), autoincrement=False, nullable=True))
    op.add_column('task_result', sa.Column('result', postgresql.BYTEA(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'task_result', type_='foreignkey')
    op.create_unique_constraint('task_result_task_id_key', 'task_result', ['task_id'])
    op.drop_index(op.f('ix_task_result_celery_taskmeta_id'), table_name='task_result')
    op.drop_column('task_result', 'celery_taskmeta_id')
    op.drop_table('celery_tasksetmeta')
    op.drop_table('celery_taskmeta')
    # ### end Alembic commands ### 
開發者ID:Salamek,項目名稱:gitlab-tools,代碼行數:16,代碼來源:d4841aeeb072_.py


注:本文中的sqlalchemy.TEXT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。