MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / pk

Method pk

lib/sqlalchemy/testing/suite/test_ddl.py:284–310  ·  view source on GitHub ↗
(self, metadata, connection)

Source from the content-addressed store, hash-verified

282 return actual_name, None
283
284 def pk(self, metadata, connection):
285 convention = {
286 "pk": "primary_key_%(table_name)s_"
287 "%(column_0_N_name)s"
288 + (
289 "_".join(
290 "".join(random.choice("abcdef") for j in range(30))
291 for i in range(10)
292 )
293 ),
294 }
295 metadata.naming_convention = convention
296
297 a = Table(
298 "a_things_with_stuff",
299 metadata,
300 Column("id_long_column_name", Integer, primary_key=True),
301 Column("id_another_long_name", Integer, primary_key=True),
302 )
303 cons = a.primary_key
304 actual_name = cons.name
305
306 metadata.create_all(connection)
307 insp = inspect(connection)
308 pk = insp.get_pk_constraint("a_things_with_stuff")
309 reflected_name = pk["name"]
310 return actual_name, reflected_name
311
312 def ix(self, metadata, connection):
313 convention = {

Callers

nothing calls this directly

Calls 6

inspectFunction · 0.90
create_allMethod · 0.80
TableFunction · 0.50
ColumnFunction · 0.50
joinMethod · 0.45
get_pk_constraintMethod · 0.45

Tested by

no test coverage detected